diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index fb9c90c..8df2a2a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,17 @@
-
+
+
+
+
-
-
-
+
+
+
+
+
+
@@ -22,9 +28,10 @@
+
@@ -96,52 +103,52 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "Docker.Dockerfile build.executor": "Run",
+ "Docker.Dockerfile.executor": "Run",
+ "Playwright.JoinText Component.executor": "Run",
+ "Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "Vitest.compute function (1).executor": "Run",
+ "Vitest.compute function.executor": "Run",
+ "Vitest.mergeText.executor": "Run",
+ "Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
+ "Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
+ "Vitest.removeDuplicateLines function.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
+ "Vitest.replaceText function.executor": "Run",
+ "git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/public/assets",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.build.executor": "Run",
+ "npm.dev.executor": "Run",
+ "npm.lint.executor": "Run",
+ "npm.prebuild.executor": "Run",
+ "npm.script:create:tool.executor": "Run",
+ "npm.test.executor": "Run",
+ "npm.test:e2e.executor": "Run",
+ "npm.test:e2e:run.executor": "Run",
+ "prettierjs.PrettierConfiguration.Package": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\prettier",
+ "project.structure.last.edited": "Problems",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "settings.typescriptcompiler",
+ "ts.external.directory.path": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -781,7 +788,6 @@
-
@@ -806,7 +812,8 @@
-
+
+
diff --git a/src/components/ToolContent.tsx b/src/components/ToolContent.tsx
index 4b45a9a..bdb1864 100644
--- a/src/components/ToolContent.tsx
+++ b/src/components/ToolContent.tsx
@@ -17,7 +17,7 @@ interface ToolContentPropsBase extends ToolComponentProps {
// Tool options
initialValues: T;
- getGroups: GetGroupsType;
+ getGroups: GetGroupsType | null;
// Computation function
compute: (optionsValues: T, input: I) => void;
diff --git a/src/components/examples/ExampleCard.tsx b/src/components/examples/ExampleCard.tsx
index cada618..41d0ba3 100644
--- a/src/components/examples/ExampleCard.tsx
+++ b/src/components/examples/ExampleCard.tsx
@@ -18,7 +18,7 @@ export interface ExampleCardProps {
sampleResult: string;
sampleOptions: T;
changeInputResult: (newInput: string, newOptions: T) => void;
- getGroups: GetGroupsType;
+ getGroups: GetGroupsType | null;
}
export default function ExampleCard({
diff --git a/src/components/examples/ExampleOptions.tsx b/src/components/examples/ExampleOptions.tsx
index cac9c94..9a3c504 100644
--- a/src/components/examples/ExampleOptions.tsx
+++ b/src/components/examples/ExampleOptions.tsx
@@ -7,12 +7,12 @@ export default function ExampleOptions({
getGroups
}: {
options: T;
- getGroups: GetGroupsType;
+ getGroups: GetGroupsType | null;
}) {
return (
);
diff --git a/src/components/examples/ToolExamples.tsx b/src/components/examples/ToolExamples.tsx
index 8bd236c..f541b94 100644
--- a/src/components/examples/ToolExamples.tsx
+++ b/src/components/examples/ToolExamples.tsx
@@ -13,7 +13,7 @@ export interface ExampleProps {
title: string;
subtitle?: string;
exampleCards: CardExampleType[];
- getGroups: GetGroupsType;
+ getGroups: GetGroupsType | null;
formRef: React.RefObject>;
setInput: React.Dispatch>;
}
diff --git a/src/components/options/ToolOptions.tsx b/src/components/options/ToolOptions.tsx
index 0061562..f0114c6 100644
--- a/src/components/options/ToolOptions.tsx
+++ b/src/components/options/ToolOptions.tsx
@@ -86,44 +86,45 @@ export default function ToolOptions({
validationSchema?: any | (() => any);
compute: (optionsValues: T, input: any) => void;
input?: any;
- getGroups: GetGroupsType;
+ getGroups: GetGroupsType | null;
formRef?: RefObject>;
}) {
const theme = useTheme();
- return (
-
-
-
- Tool options
-
-
- {}}
- >
- {(formikProps) => (
-
- {children}
-
- )}
-
+ if (getGroups)
+ return (
+
+
+
+ Tool options
+
+
+ {}}
+ >
+ {(formikProps) => (
+
+ {children}
+
+ )}
+
+
-
- );
+ );
}
diff --git a/src/pages/tools/json/index.ts b/src/pages/tools/json/index.ts
index 48d4333..3e27468 100644
--- a/src/pages/tools/json/index.ts
+++ b/src/pages/tools/json/index.ts
@@ -1,3 +1,4 @@
import { tool as jsonPrettify } from './prettify/meta';
+import { tool as jsonMinify } from './minify/meta';
-export const jsonTools = [jsonPrettify];
+export const jsonTools = [jsonPrettify, jsonMinify];
diff --git a/src/pages/tools/json/minify/index.tsx b/src/pages/tools/json/minify/index.tsx
new file mode 100644
index 0000000..04532d4
--- /dev/null
+++ b/src/pages/tools/json/minify/index.tsx
@@ -0,0 +1,77 @@
+import React, { useState } from 'react';
+import ToolContent from '@components/ToolContent';
+import ToolTextInput from '@components/input/ToolTextInput';
+import ToolTextResult from '@components/result/ToolTextResult';
+import { minifyJson } from './service';
+import { CardExampleType } from '@components/examples/ToolExamples';
+import { ToolComponentProps } from '@tools/defineTool';
+
+type InitialValuesType = Record;
+
+const initialValues: InitialValuesType = {};
+
+const exampleCards: CardExampleType[] = [
+ {
+ title: 'Minify a Simple JSON Object',
+ description:
+ 'This example shows how to minify a simple JSON object by removing all unnecessary whitespace.',
+ sampleText: `{
+ "name": "John Doe",
+ "age": 30,
+ "city": "New York"
+}`,
+ sampleResult: `{"name":"John Doe","age":30,"city":"New York"}`,
+ sampleOptions: {}
+ },
+ {
+ title: 'Minify a Nested JSON Structure',
+ description:
+ 'This example demonstrates minification of a complex nested JSON structure with arrays and objects.',
+ sampleText: `{
+ "users": [
+ {
+ "id": 1,
+ "name": "Alice",
+ "hobbies": ["reading", "gaming"]
+ },
+ {
+ "id": 2,
+ "name": "Bob",
+ "hobbies": ["swimming", "coding"]
+ }
+ ]
+}`,
+ sampleResult: `{"users":[{"id":1,"name":"Alice","hobbies":["reading","gaming"]},{"id":2,"name":"Bob","hobbies":["swimming","coding"]}]}`,
+ sampleOptions: {}
+ }
+];
+
+export default function MinifyJson({ title }: ToolComponentProps) {
+ const [input, setInput] = useState('');
+ const [result, setResult] = useState('');
+
+ const compute = (_: InitialValuesType, input: string) => {
+ if (input) setResult(minifyJson(input));
+ };
+
+ return (
+
+ }
+ resultComponent={}
+ initialValues={initialValues}
+ getGroups={null}
+ toolInfo={{
+ title: 'What Is JSON Minification?',
+ description:
+ "JSON minification is the process of removing all unnecessary whitespace characters from JSON data while maintaining its validity. This includes removing spaces, newlines, and indentation that aren't required for the JSON to be parsed correctly. Minification reduces the size of JSON data, making it more efficient for storage and transmission while keeping the exact same data structure and values."
+ }}
+ exampleCards={exampleCards}
+ input={input}
+ setInput={setInput}
+ compute={compute}
+ />
+ );
+}
diff --git a/src/pages/tools/json/minify/meta.ts b/src/pages/tools/json/minify/meta.ts
new file mode 100644
index 0000000..18ec46d
--- /dev/null
+++ b/src/pages/tools/json/minify/meta.ts
@@ -0,0 +1,12 @@
+import { defineTool } from '@tools/defineTool';
+import { lazy } from 'react';
+
+export const tool = defineTool('json', {
+ name: 'Minify JSON',
+ path: 'minify',
+ icon: 'lets-icons:json-light',
+ description: 'Minify your JSON by removing all unnecessary whitespace and formatting. This tool compresses JSON data to its smallest possible size while maintaining valid JSON structure.',
+ shortDescription: 'Remove all unnecessary whitespace from JSON data.',
+ keywords: ['minify', 'compress', 'minimize', 'json', 'compact'],
+ component: lazy(() => import('./index'))
+});
diff --git a/src/pages/tools/json/minify/service.ts b/src/pages/tools/json/minify/service.ts
new file mode 100644
index 0000000..a5bbc50
--- /dev/null
+++ b/src/pages/tools/json/minify/service.ts
@@ -0,0 +1,10 @@
+export const minifyJson = (text: string) => {
+ let parsedJson;
+ try {
+ parsedJson = JSON.parse(text);
+ } catch (e) {
+ throw new Error('Invalid JSON string');
+ }
+
+ return JSON.stringify(parsedJson);
+};