How to use Minify JSON

  1. Paste JSON or JSON Lines into the Input JSON editor, or click Select files to load a file.
  2. Read the compact output in the Minified JSON panel; it is produced automatically whenever the input changes.
  3. If the panel shows an error message instead, correct the reported problem in the input.
  4. Click Copy to clipboard, or Download to save the output as a .json file (.jsonl for JSON Lines input).

Examples

Simple object

Input: an object written over several lines containing "name": "John Doe", "age": 30 and "city": "New York". Output: {"name":"John Doe","age":30,"city":"New York"}.

JSON Lines

Input: { "a" : 1 } on one line, a blank line, then { "b" : [ 1, 2 ] }. Output: {"a":1} and {"b":[1,2]} on two lines, with the blank line removed.

Good to know

  • Standard JSON is parsed with JSON.parse and written back with JSON.stringify. This removes all whitespace between tokens. String values keep their content, but escape sequences such as \u00e9 or \/ are written out as plain characters.
  • If the input is not a single JSON document but every non-blank line is valid JSON, it is treated as JSON Lines. Each record is minified onto its own line and blank lines are dropped.
  • Values are re-serialized by JavaScript. Integers larger than 9007199254740991 can lose precision, numbers are rewritten in JavaScript form (1.0 becomes 1, 1e2 becomes 100), and if a key appears twice in the same object only its last value is kept.
  • Invalid input is not minified. The Minified JSON panel shows the parser error instead, starting with Invalid JSON, or with Invalid JSON at line N when the input has more than one non-blank line.
  • The input and output editors use the Monaco code editor. The page downloads it from cdn.jsdelivr.net when an editor loads.

Frequently asked questions

Is whitespace inside string values removed?

No. Only whitespace between JSON tokens is removed. A value such as "keep these spaces" keeps its spaces.

Can I minify an NDJSON or JSON Lines file?

Yes. If every non-blank line is valid JSON, each record is minified on its own line, and Download saves the result with a .jsonl extension.

More JSON Tools