To minify JSON in IntelliJ, copy the strict JSON into JSON Minifier, run the minification, verify the compact result, and paste it back into the IDE.

This is a browser-assisted IntelliJ workflow, not an IntelliJ plug-in. JSON Minifier parses and serializes the value in the current browser tab, while IntelliJ remains the place where you select, review, and replace the source. If you require an IDE-only command, this guide does not claim that the tool is installed or callable inside IntelliJ.

Parsing, validation, serialization, display, and copying all happen locally in the browser tab. The input is not uploaded to Lizely or sent to an API. This distinction also keeps the operation accurate: IntelliJ’s Reformat Code command controls readable source layout, but it is not a substitute for the specific compact JSON.parse-then-JSON.stringify output defined here.

how to minify json in intellij
How to Minify JSON in IntelliJ: Browser-Assisted Workflow

Minify JSON while working in IntelliJ

Use this sequence for a .json file, a selected JSON value, an API request body, or another JSON snippet that you are editing in IntelliJ.

  1. Protect the original. Save the file or commit your current work before replacing content. That gives you a clean rollback point if the receiving application expects a different representation.
  2. Select the JSON value. In IntelliJ, select exactly the object, array, string, number, boolean, or null text you want compacted. Do not include surrounding code, comments, or a trailing comma because the minifier accepts strict JSON only.
  3. Paste it into the browser tool. Open JSON Minifier, paste the selection into the input area, and review the displayed input character count. Empty input is rejected, so confirm that the complete value was copied.
  4. Run Minify JSON. Select the Minify JSON control. The tool validates the structure before producing a compact serialization instead of deleting arbitrary characters.
  5. Resolve any reported error. Fix the strict-syntax, duplicate-key, unsafe-number, nesting, or character-budget problem in the source, then paste the corrected value again. A failed parse does not leave an earlier successful result visible, which helps prevent an accidental copy of stale output.
  6. Check the compact result. Confirm that the output and character-reduction summary appear. Compare the strings, object members, and arrays with the source before replacing anything.
  7. Copy the complete minified JSON. Use the tool’s copy action. If clipboard access is denied, the output remains visible for manual selection. If the input changes while copying, wait for the current result and copy it again rather than relying on an outdated status message.
  8. Return to IntelliJ and replace the original block. Select the same original JSON text, paste the minified value, and save the file. Keep the browser tab available until the replacement is complete so you can compare the source and output again if necessary.

If a problem is primarily invalid JSON syntax, the JSON Validator can be used for syntax-only diagnosis before you return the corrected text to IntelliJ.

What the compact output preserves

The result is the compact text produced by native JSON.parse followed by JSON.stringify. JSON Minifier is therefore a parser and serializer, not a regular-expression whitespace remover. It removes formatting whitespace only where the JSON grammar treats that whitespace as insignificant.

Spaces and line breaks outside strings can disappear. Spaces, tabs represented by escapes, punctuation, and line-break escapes inside a string are data and remain part of the decoded value. The scanner tracks strings and escape sequences, so a brace, comma, or quote-looking character inside a string does not alter the structure it detects.

Input detail Result after minification
Spaces, tabs, and line breaks outside strings Removed as insignificant formatting whitespace.
Spaces, escaped tabs, punctuation, and escaped line breaks inside strings Retained as string data.
Object member order Follows JavaScript parsing and serialization behavior.
Array item order Preserved.
Object keys and fields Keys are not sorted, and fields are not removed.
Repeated array items Not deduplicated.

The output is not promised to match every input token byte for byte. Number spellings can be canonicalized, while object member order follows the behavior of JavaScript objects rather than a separate sorting rule. The tool does not validate an application-specific schema, change array order, or remove data that a particular endpoint may require.

Errors that stop the minifier

Strictness is valuable because minification should not conceal a malformed or ambiguous source. The tool rejects JavaScript object literals and JSON5 constructs rather than repairing them. Examples include comments, trailing commas, single-quoted strings, unquoted property names, hexadecimal numbers, leading plus signs, Infinity, NaN, undefined, functions, and sparse array syntax.

Condition Tool behavior Action in IntelliJ
Duplicate member name in one object Rejected explicitly, including escape-equivalent names. Rename or remove the duplicate in the source, then retry.
Invalid strict-JSON syntax Rejected without repairing the text. Convert the JavaScript or JSON5 construct to strict JSON.
Unsafe numeric token Rejected instead of being silently rewritten. Use a quoted identifier or an appropriate arbitrary-precision system.
Nesting beyond 256 levels Rejected before parsing; no partial result is returned. Redesign the structure only if the application permits it.
Input or output beyond its budget Rejected without truncating or partially returning the JSON. Reduce or split the data only when the surrounding workflow supports it.

Duplicate detection is scoped to a single object. The same member name can appear in separate nested objects because they have different member scopes. Keys are compared after escape decoding, so two differently written keys that decode to the same name count as duplicates. Native JSON.parse alone would retain only the last value, so the explicit rejection prevents minification from hiding a last-key-wins data change.

Number checks also go beyond ordinary integer syntax. The tool rejects every parsed integer outside JavaScript’s safe-integer range, including integer-valued decimal or exponent forms; the exact safe boundaries are accepted. It rejects non-finite overflow and a nonzero token that would underflow to zero. It also rejects a decimal token when its exact base-10 value differs from the shortest JSON.stringify spelling of the parsed number, while numerically equivalent spellings remain accepted. Finite fractional values use normal ECMAScript Number semantics, and the serializer may choose a canonical decimal or exponent spelling for the same represented value. If exact arbitrary-precision spelling or a very large identifier matters, encode it as a JSON string or use a purpose-built arbitrary-precision system.

Limits and state changes to account for

JSON Minifier has explicit boundaries so it never silently slices, samples, or partially returns a result. The maximum input size is 1,000,000 UTF-16 code units, and output has an independent 1,000,000-code-unit budget. Each exact boundary is accepted, while the next character is rejected. Empty input is also rejected, and nesting is limited to 256 levels before JSON.parse.

  • Native JSON.parse remains the final syntax authority, while native JSON.stringify produces the displayed compact text.
  • Editing the input immediately removes the previous result, error, reduction summary, and copy status.
  • A failed parse never leaves an earlier successful output visible.
  • Clipboard denial leaves the compact output visible for manual selection.
  • The output is normally no longer than the input because formatting whitespace is removed, but the independent output budget still applies.

The reduction summary shows the input-to-output character reduction; it does not prove semantic fitness for an API. Before replacing an IntelliJ file, check whether the receiving system expects the same member order, number representation, object shape, and array contents. Also review credentials and personal data before copying the result into another system.

When compact JSON is the wrong format

Compact JSON suits API fixtures, configuration snippets, request bodies, embedded examples, JSON log entries, test cases, and transport payloads where ordinary formatting whitespace is unnecessary. It is not a substitute for gzip or another compression method, and a smaller character count alone does not make data smaller after transport compression.

  • Keep readable indentation while debugging or reviewing a structure; use the JSON Formatter when you need a formatted copy.
  • Check syntax separately when you need only validation and diagnostics.
  • Keep exact large identifiers as strings or handle them with an arbitrary-precision system.
  • Do not treat minified JSON as executable code or as a way to make untrusted data safe to run.

Minification does not validate an application schema, redact secrets, compress with gzip, convert JSON into JavaScript, or make untrusted content safe to execute. Use the browser-assisted copy-and-replace workflow when you need the defined compact JSON.parse-and-JSON.stringify result, and keep the original IntelliJ file until the application has accepted the replacement.

For a deeper look, see How to Generate JSON Schema from a Java Class.

For a deeper look, see JSON to CSV: Command Line vs Online Compared.