Skip to content

JSON Minify

Remove whitespace from JSON. {"a": 1, "b": [2, 3]} becomes {"a":1,"b":[2,3]}. The page does not fetch JSON from a URL.

Result

Paste JSON

How to Use

  1. 1 Paste JSON up to 200000 characters.
  2. 2 Choose Minify JSON.
  3. 3 {"a": 1, "b": [2, 3]} is the sample.

Example Output

  • {"a": 1, "b": [2, 3]}

About This Tool

The input must be one valid JSON value. Nesting deeper than 30 levels or longer than 200000 characters is rejected.

Using JSON Minify

JSON Minify removes whitespace from one JSON value. The JSON field begins as {"a": 1, "b": [2, 3]}. Choose Minify JSON. The label above the headline reads JSON. The headline is Minified JSON. The text is {"a":1,"b":[2,3]}. The Characters line is 17. Download JSON saves that text as minified.json.

The page parses the paste, rejects a value that is not valid JSON, rejects nesting past the depth check, and encodes the value again without pretty printing. The steps under the result say to parse the JSON, reject invalid or over-deep JSON, and encode again without pretty printing. Spaces after the colons and the commas in the sample are gone. The keys, the numbers, and the brackets stay. The headline is the words Minified JSON. The character count sits on its own line and is not the headline.

A paste longer than 200000 characters is rejected before it is parsed. The message is JSON must be at most 200000 characters. A paste of 200000 characters still reaches the parser. A string of 200000 copies of the letter a is inside that length, and the page then says Enter valid JSON. An empty field says Enter valid JSON. A lone opening brace says Enter valid JSON. A value nested more than 30 levels deep says JSON must not be nested more than 30 levels deep.

Copy result copies the minified text. For the sample, that copy is {"a":1,"b":[2,3]}. It does not copy the headline Minified JSON or the Characters line. Reset returns the field to {"a": 1, "b": [2, 3]} and the headline to Paste JSON. Copy the text before you reset. Minify JSON on the sample twice and the text stays {"a":1,"b":[2,3]} and Characters stays 17. The page does not fetch JSON from a URL. The field is the whole input.

What Minified JSON and 17 Measure

The headline names the kind of result. It reads Minified JSON on every successful run, including the sample. The text under it is the encoded value. For the starting field, that text is {"a":1,"b":[2,3]}. The Characters line counts the characters in that text. Seventeen is the length of {"a":1,"b":[2,3]}, not the length of the paste you started with. The sample paste has spaces after the colon and after each comma, so the paste is longer than 17 characters. The line reports the encoded length.

The page does not return the original spacing as a second result. You can still see the paste in the field until you edit it or reset. The text is the compact encoding. A key named a set to the number 1, and a key named b set to an array of 2 and 3, are both in that text. The order of those keys follows the paste. The array stays an array. The numbers stay numbers.

Download JSON writes the same text into a file named minified.json. The button label is Download JSON. The file is the encoded value, which for the sample is {"a":1,"b":[2,3]}. Characters 17 describes that file as well as the text on the page. If you need the count in a note, write 17 beside the copy. The headline words Minified JSON are not inside the file.

The control that runs the encode says Minify JSON. The field label is JSON. The waiting headline, which is also the headline after reset, is Paste JSON. The about line says the input must be one valid JSON value, and that nesting deeper than 30 levels or longer than 200000 characters is rejected. Under a successful result the steps always read Parse the JSON, Reject invalid or over-deep JSON, and Encode again without pretty printing. Those three lines describe the run. They are not a second copy of {"a":1,"b":[2,3]}.

How the Sample Loses Its Spaces

The page reads the field as one JSON value. It does not trim a length check before the parse: a string longer than 200000 characters stops with JSON must be at most 200000 characters. A shorter string is decoded. If that decode fails, the message is Enter valid JSON. If the decode succeeds, the page walks arrays and objects and rejects a nesting deeper than 30 levels with JSON must not be nested more than 30 levels deep. The value that passes is encoded again without pretty printing. Slashes stay slashes. Letters such as é stay themselves rather than turning into escape codes.

Indenting a value for reading is a different page. The JSON Prettifier formats one JSON value with line breaks and four-space indentation. {"a":1} becomes a readable object that still contains a and 1. The headline is Formatted JSON. Characters on that run is 14. Invalid JSON is rejected with Enter valid JSON. A paste outside 1 to 20000 characters says Enter from 1 to 20000 characters. That page does not fetch JSON. Use it when you want the object broken onto lines. Use this page when {"a": 1, "b": [2, 3]} should become {"a":1,"b":[2,3]} with Characters 17.

One Value, No URL, No Second Mode

The field holds the whole input. There is no URL box, no file picker, and no second field for a schema. The intro on the page says the page does not fetch JSON from a URL. If the JSON lives at an address, copy the value into the field yourself. The about line says the input must be one valid JSON value, and that nesting deeper than 30 levels or longer than 200000 characters is rejected.

From the Sample Paste to 17 Characters

Leave the field as {"a": 1, "b": [2, 3]}. Choose Minify JSON. The headline is Minified JSON. The text is {"a":1,"b":[2,3]}. Characters is 17. Choose Minify JSON again. The text and the count match. Choose Download JSON if you want minified.json to hold that same text. Clear the field and choose Minify JSON. The headline reads Enter valid JSON. Type a single opening brace and choose Minify JSON. The headline reads Enter valid JSON again. Restore the sample and confirm Characters is 17.

Rows of comma-separated text are a different conversion. The CSV to JSON Converter turns a header row and data rows into a JSON array. a,b followed by 1,2 becomes one object with a set to the text 1 and b set to the text 2. The headline is 1 row. Columns is 2. The values stay text. The page does not open a file. Use it when the paste is CSV. Use this page when the paste is already JSON and the sample should encode as {"a":1,"b":[2,3]}.

Counts and Shapes People Mix Up

A common miss is to treat Characters 17 as the length of the paste. The sample paste includes spaces. The line counts the encoded text {"a":1,"b":[2,3]}. Another miss is to expect an empty object to stay an empty object. Paste {} and choose Minify JSON. The text is [] and Characters is 2. The page decodes the value and encodes it again, and that empty object encodes as an empty array. An empty array [] stays []. Another miss is to read the headline as the JSON. The headline is Minified JSON. The JSON is the text.

A comparison of two numbers is a different calculation. The Percentage Difference Calculator uses the absolute difference divided by the average of the absolute values, times 100. The absolute difference of 40 and 50 is 10. The average of the absolute values is 45. The percentage difference is 22.22. That page does not encode JSON. Use it when you are comparing two numbers. Use this page when {"a": 1, "b": [2, 3]} should become {"a":1,"b":[2,3]}.

Keeping the Text and the Count

Copy the text before you reset. For the sample, the copy is {"a":1,"b":[2,3]}. Write Characters 17 next to it if the note needs the length. A note that says only Minified JSON does not hold the value. A note that says only 17 can be the input length or the output length. The text plus the count keeps those apart. Download JSON saves minified.json with the text and without the headline.

Solving a straight line for x is a different page. The Inverse Function Calculator solves y = ax + b. Slope 2, intercept 3, and y 11 give x = 4. The sentence says for y = 2x + 3, y = 11 gives x = 4. That page does not encode JSON and does not save minified.json. Use it when the unknown is x on that line. Use this page when the input is JSON and the sample text should be {"a":1,"b":[2,3]}.

The Compact Value You Can Copy

The headline Minified JSON means the encode succeeded. From {"a": 1, "b": [2, 3]} the text is {"a":1,"b":[2,3]} and Characters is 17. From {"a":1} the text is {"a":1} and Characters is 7. From [true, false, null] the text is [true,false,null] and Characters is 17. From {} the text is [] and Characters is 2. From a number inside 30 arrays, Characters is 61. Those figures come from the field on that run.

Checking the Encoded Text

Compare the text with the paste. Keys and values should match once insignificant spaces are ignored. For the sample, a is 1 and b is the array 2, 3. Count the characters in the text and compare that number with the Characters line. For {"a":1,"b":[2,3]} the count is 17. If the text still has spaces after colons, you are looking at the field, not the result. If the headline is an error sentence, there is no encoded text to count.

A list of numbers has a center that this page does not compute. The Mean Absolute Deviation Calculator summarizes a list. The values 5, 5, 5 have a mean absolute deviation of 0. The sentence says mean absolute deviation 0, mean 5, and count 3. That page does not encode JSON. Use it when the input is a list of numbers. Use this page when the input is one JSON value and the sample should encode as {"a":1,"b":[2,3]}. A deviation of 0 is not Characters 17.

Frequently Asked Questions

What does {"a": 1, "b": [2, 3]} return?

The headline is Minified JSON. The text is {"a":1,"b":[2,3]}. Characters is 17. Download JSON saves that text as minified.json. The label above the headline reads JSON.

What does Characters count?

It counts the encoded text, not the paste. The sample paste has spaces. The text {"a":1,"b":[2,3]} is 17 characters, so the line is 17. {"a":1} is 7. [true,false,null] is 17. {"u":"café","p":"a/b"} is 23.

What if the JSON is invalid?

The headline reads Enter valid JSON. An empty field, a lone opening brace, and a string of 200000 copies of the letter a all use that message. The text is not a successful encode on that run.

What is the length limit?

JSON must be at most 200000 characters. A longer paste is rejected with that message before the parse. A paste of 200000 characters is parsed. If it is not JSON, the message is Enter valid JSON.

What is the depth limit?

JSON must not be nested more than 30 levels deep. A number wrapped in 30 arrays is accepted, and Characters is 61. A number wrapped in 31 arrays is rejected with that depth message.

What does an empty object become?

Paste {} and choose Minify JSON. The text is [] and Characters is 2. The page decodes the value and encodes it again, and that empty object encodes as an empty array. An empty array stays [].

What does Download JSON save?

It saves minified.json. The file is the text on the page. For the sample, the file is {"a":1,"b":[2,3]}. The headline Minified JSON and the Characters line are not written into the file. The label on the control is Download JSON.

What does reset restore?

The field returns to {"a": 1, "b": [2, 3]}. The headline returns to Paste JSON. The text and the Characters line clear. Choose Minify JSON again when you want {"a":1,"b":[2,3]}, Characters 17, and the file name minified.json.