Using the JSON Prettifier
This page formats one JSON value with line breaks and four-space indentation. The sample {"a":1} becomes a formatted object. An opening brace is on its own line. The next line is four spaces, then the quoted key a, a colon, a space, and the number 1. A closing brace is on its own line. The key a is set to the number 1, so the 1 is not inside quotes. The headline is Formatted JSON. The page does not fetch JSON. A string inside the value is not a request, even when the string looks like an address.
The text under the headline is the formatted JSON, and that text is what you copy. A line counts the characters in the formatted value. The field accepts from 1 to 20000 characters. A blank field, or a longer paste, is rejected before formatting. Invalid JSON is rejected with Enter valid JSON. The sample is valid, so the rejection is not what the sample demonstrates. Reset returns the field to {"a":1}.
An array, a string, a number, true, false, and null are JSON values too, and each one is formatted as one value. Two values side by side are not one value, and they are rejected. Slashes in strings stay slashes. A character outside ASCII stays that character. The page writes the value after it has parsed, which is why invalid JSON never receives indentation.
Look at the sample one token at a time after it is formatted. The opening brace stands alone. Four spaces follow on the next line, then a quotation mark, the letter a, a quotation mark, a colon, a space, and the digit 1. The closing brace stands alone on the last line. That digit is a number because it is the JSON number 1, not the string 1. The headline Formatted JSON sits above those lines and is not one of them. The page does not fetch JSON, so a longer document you hoped would appear does not appear. If the middle line loses the four spaces, the write was not this page's indentation. If the digit gains quotes, the value is no longer the sample number. Enter valid JSON remains the message when the paste does not parse, and that message is not a formatted object you can indent further by submitting it again.
What the Formatted Object Shows
The formatted sample is three lines. The first line is an opening brace. The second line begins with four spaces and contains "a": 1, with a space after the colon and no quotes around the number 1. The third line is a closing brace. The key is a. The value is the number 1. The headline is Formatted JSON, which names the result without replacing those three lines. Copy the text under the headline when you want the indented object. The character count is the length of that text, including the line breaks and the four spaces. The page does not fetch JSON, so nothing is added from outside the field.
{"a":1} and the formatted object are the same JSON value written two ways. The compact form has no space after the colon. The formatted form has a space after the colon and a line break around the pair. The key stays a. The number stays 1. Invalid JSON does not get a partial version of this layout. The message is Enter valid JSON, and there is no formatted text to copy from that rejection.
How the Sample Is Indented
The page trims the ends of the paste, checks the length, and parses the text as one JSON value. When the parse succeeds, it writes the value again with line breaks and four-space indentation. For {"a":1} that write produces the opening brace, the indented line with the key a set to the number 1, and the closing brace. The headline is Formatted JSON. Run the sample twice. The three lines match. The page does not fetch JSON on either run. A paste that is not valid JSON stops at Enter valid JSON and does not indent the broken text.
Compacting is the other direction. The JSON Minifier parses a JSON value and writes it without insignificant space. {"a": 1} becomes {"a":1}. The headline there is a character count, and that compact value is 7 characters. Invalid JSON is rejected rather than trimmed by hand. That page does not add the four-space line the sample uses here. Use it when you want {"a":1} with the space removed. Use this page when you want {"a":1} expanded so the key a sits on its own indented line as the number 1.
What the Page Does Not Fetch
The page does not fetch JSON. {"a":1} is formatted from the characters in the field. If a string in a larger value contains an address, the page does not request that address and does not replace the string with a document from the network. The indentation is a rewrite of a value that already parsed. Enter valid JSON is the stop for a value that did not parse. There is no second step that goes looking for a corrected file.
The rewrite keeps the parsed meaning. The key a stays a key. The number 1 stays a number. A string value would keep its quotes. true, false, and null stay those tokens. An array is indented with the same four spaces. Two objects written one after another are rejected because they are not one JSON value. The page will not wrap them in an array for you. Put them in one array yourself if that is the value you meant, then format that single value. The page still does not fetch JSON.
The Sample and a Rejected Brace
Paste {"a":1}. Confirm the headline is Formatted JSON. Confirm the first line is an opening brace, the middle line is four spaces and "a": 1, and the last line is a closing brace. Confirm the 1 has no quotes. Paste { and confirm the rejection Enter valid JSON. Paste nothing but spaces and confirm the page asks you to enter from 1 to 20000 characters, which is the empty-field message rather than the invalid-JSON message. Paste [1,2] and confirm an array is accepted and indented by four spaces. The page does not fetch JSON for the object, the array, or the rejected brace.
Rows in a table are a different shape. The JSON to CSV Converter turns a JSON array of objects into CSV. [{"a":1,"b":2}] becomes a header row a,b and a data row 1,2. Download CSV saves those rows, and that page does not write the sample object with four-space indentation under the headline Formatted JSON. Use it when you want those two CSV rows. Use this page when you want {"a":1} indented.
One Value, Four Spaces
The indentation is four spaces. There is no control to choose two spaces or a tab. The sample's middle line always starts with four spaces before the quoted key a. The page accepts one JSON value up to 20000 characters. Invalid JSON is rejected with Enter valid JSON. The page does not fetch JSON to replace a broken paste or to load a value that was named inside a string. Slashes stay unescaped. Characters outside ASCII stay as those characters.
Key order is the order the keys were parsed. The page does not sort keys alphabetically. A number may be written in ordinary JSON number form, so a value that was 1.0 can come back as 1. That is the write step after a successful parse. It is not a second edit you apply by hand. If you need the compact form instead of the indented form, this page will not remove the line breaks. The sample exists to add them.
Mistakes That Skip the Parse
The usual miss is to add line breaks by hand and skip the parse. This page indents only after the value parses. A lone brace is rejected with Enter valid JSON. Another miss is to expect the headline Formatted JSON to be the object. The object is the text under the headline. Another miss is to quote the number 1. In the sample the key a is set to the number 1, so the 1 has no quotes. Another miss is to paste two objects and expect both to be indented. They are not one value. Another miss is to think the page loaded JSON because the result looks like a document. The page does not fetch JSON.
A header row is the other way into objects. 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 1 and b set to 2. That page does not open a file, and it does not start from {"a":1} or use the headline Formatted JSON. Use it when you have rows. Use this page when you already have one JSON value to indent.
Keeping the Indented Value
Copy the three lines and keep {"a":1} beside them until you have checked the key and the number. The middle line should show four spaces, the key a, a colon, a space, and the number 1. The headline should be Formatted JSON. If your own value has more keys, read the first and last lines before you trust the middle. An object still starts with { and ends with }. An array still starts with [ and ends with ]. A rejection that says Enter valid JSON produced nothing to copy. A rejection about 20000 characters is the length cap, and shortening the paste is the next step only after the JSON is valid. When you store the sample, store the compact form and the formatted form as a pair. The compact form is {"a":1}. The formatted form breaks that value across lines and indents the key by four spaces. Either form is the same key a set to the number 1. A note that keeps only the headline has the name of the result and has lost the value. The page does not fetch JSON, so the pair in your note is the whole record of what the field contained and what the write returned.
The page does not keep a history. Reset brings {"a":1} back into the field. Format again if you want the three lines back on screen. Do not describe the formatted text as a file that was downloaded. The page does not fetch JSON. The lines are the sample value written with breaks and four-space indentation.
Formatting the Sample Again
Enter {"a":1}. Confirm the headline Formatted JSON and the indented line where the key a is set to the number 1. Run it again and confirm the same three lines. Enter { and confirm Enter valid JSON. Enter a space-only field and confirm the length message. Enter [1,2] and confirm four-space indentation of an array. The page does not fetch JSON during these checks. The number 1 in the sample stays a number, without quotes, on every successful format of that object.
An XML document uses tags instead of braces. The XML Formatter indents an XML document. <a><b>Hi</b></a> is formatted with each element on its own line. The headline is Formatted XML. That page does not fetch a file, and it does not accept a document type. It does not turn {"a":1} into the four-space JSON object. Use it when you want indented elements. Use this page when you want the key a set to the number 1 on its own indented line.
What the Four Spaces Mean
The four spaces mean the value parsed and was written with indentation. For {"a":1}, they sit before the key a, and the number 1 follows the colon. The headline Formatted JSON means that write finished. Enter valid JSON means it did not. The character count measures the formatted text, not the headline words. The page does not fetch JSON, so the three lines came from the field. A slash that stayed a slash was written that way on purpose. A second value that was rejected was never wrapped for you.
You can say {"a":1} becomes formatted JSON with four-space indentation and the key a set to the number 1. You can say the headline is Formatted JSON. You can say invalid JSON is rejected with Enter valid JSON. You can say the page does not fetch JSON. You cannot say a lone brace was repaired. You cannot say two side-by-side values were accepted as one document. Describe the middle line completely: four spaces, a quoted a, a colon, a space, and an unquoted 1. Leaving out the four spaces describes a different layout. Quoting the 1 describes a string, and the sample value is a number. The headline names the result. The lines are the result. The page does not fetch JSON to add a key the field did not contain.
Checking the Indented Sample
Start with {"a":1}. Confirm four spaces on the middle line, the key a, and the number 1 without quotes. Confirm the headline is Formatted JSON. Then reject a lone brace with Enter valid JSON. Then reject a blank field with the length message, so the two failures stay distinct. Then format an array and confirm the same four-space indent. The page does not fetch JSON, so none of these checks should wait on a network. If the 1 is quoted, the sample value was read as a string. In the sample it is a number.
A token is a different piece of JSON-shaped text. The JWT Decoder decodes the header and the payload of a JSON Web Token. The page does not check the signature, so a decoded payload is not proof that the token is genuine. The signature line reads Not checked. That page does not indent {"a":1} under the headline Formatted JSON. Use it when you have a token. Use this page when you have one JSON value and want the four-space layout.