Minify JSON Online

Minify JSON in your browser: paste JSON, press Minify, and get the same JSON on one line, with the spaces, tabs and line breaks between tokens removed. Strings and numbers are kept as written, so 18.00 stays 18.00. Invalid JSON comes back as the first parse error, naming the line the parser stopped on. Nothing is uploaded unless you save or share.

About Online JSON Minifier

Paste JSON into the Source JSON field and press Minify: the result box shows the same JSON on one line, without the spaces, tabs and line breaks between keys, values, commas and brackets. Spaces inside strings stay, and numbers are copied as typed, so long integers are not rounded. Format turns minified JSON back into indented JSON, and Fix repairs common syntax mistakes before minifying.

  • Minify JSON to a single line, without the whitespace between tokens
  • Keep strings, numbers and key order exactly as typed
  • Validate JSON and get the first parse error with its line number
  • Format minified JSON back into readable JSON
  • Fix common JSON errors: single quotes, unquoted keys, trailing commas and comments
  • Upload a JSON file from your disk
  • Download the minified JSON as a .json file
  • Share minified JSON by link
  • Free to use

What is JSON minification?

JSON minification removes the whitespace that only makes JSON readable: the spaces, tabs and line breaks between keys, values, commas and brackets. Whitespace inside a string is part of the data and is kept. Minified JSON parses to the same value as the original, so a program that reads it gets the same data.

Why minify JSON?

Minified JSON is smaller, so API responses, configuration files and stored data take fewer bytes to send and keep. The example below shrinks from 89 to 64 bytes, by 28%; the deeper the indentation, the more a document saves.

How to minify JSON online?

Paste JSON into the Source JSON field, or press Upload to open a .json file, then press Minify. Copy the result or press Download to save it as data.json. To read minified JSON again, press Format: it comes back indented with four spaces.

How does the JSON minifier work?

The page parses the JSON in your browser first. If the parser stops, the result box shows the line and the token it stopped on instead of a result. Valid JSON is then copied with the whitespace between tokens dropped and every string kept whole. Numbers are not converted, so 18.00 and 12345678901234567890 come out as typed.

JSON Minify Example

Below is an example of indented JSON and the minified result.

Original JSON Example
{
    "Id": 78912,
    "Customer": "Jason Sweet",
    "Quantity": 1,
    "Price": 18.00
}

Minified JSON Result
{"Id":78912,"Customer":"Jason Sweet","Quantity":1,"Price":18.00}

JSON Minification Rules

  • Spaces, tabs, line breaks and carriage returns between tokens are removed.
  • Whitespace inside string values is kept.
  • Numbers, true, false and null are kept as written.
  • Keys keep their order, and repeated keys are kept.
  • Escape sequences such as \n and é stay escaped.
  • Comments are not valid JSON: Minify reports them as an error, Fix removes them.

How to minify JSON in JavaScript and Python?

In JavaScript, JSON.stringify(JSON.parse(text)) returns minified JSON. In Python, json.dumps(data, separators=(",", ":")) does the same. Both parse the numbers first: JavaScript turns 18.00 into 18 and rounds integers above 253, and Python turns 18.00 into 18.0. This page keeps them as typed.

Online JSON Formatter

To read and validate JSON with the indentation of your choice, use the JSON Formatter, which formats JSON with 2 spaces, 4 spaces or tabs and shows it as a collapsible tree.

Updated: