Dev Toolbox · Windows 10 and 11

JSON formatter and validator

Paste JSON and it comes back indented and readable, or squeezed onto one line, while you type. When it is broken, you get the parser's own explanation instead of a result, so you know what to fix. It runs inside Octoolo on your PC, so the API responses and customer records you paste stay there.

Updated

How to format JSON

  1. 1

    Open the JSON formatter

    Open the Dev Toolbox from Octoolo's home screen and pick JSON formatter, the first tool under Data. Typing json into the home screen's search box gets you there too.

  2. 2

    Paste your JSON

    Paste it into the Input pane, or type. The Result pane updates on every keystroke, so there is no Format button to press.

  3. 3

    Pick the layout

    Under Format, choose 2 spaces, 4 spaces, Tabs or Minify. Switch on Sort keys to put the keys of every object in alphabetical order.

  4. 4

    Copy it, or fix it

    Press Copy above the result. If the input is not valid, the result stays empty and a note under the panes reads Not valid JSON, followed by the reason.

Pretty-printed, minified, sorted: what changes and what does not

Outside of strings, JSON ignores spaces, tabs and line breaks. A formatter only adds or removes that whitespace, so the data you get back is the same data: the same keys, the same values, the same order of items in every array. What changes is who it is easy to read for.

  • 2 or 4 spaces for reading, code reviews and config files. Two spaces keep deep nesting from drifting off the right edge; four make each level easier to tell apart.
  • Tabs when your project indents with tabs, or when you want each reader's editor to choose the width.
  • Minify for sending: one line, no spaces between tokens. Indentation costs bytes on every line, so minified JSON is what belongs in request bodies, environment variables and single-line fields.

Sort keys reorders the keys inside every object, at every depth, including objects inside arrays. The JSON standard treats an object's keys as unordered, so nothing a program reads changes. It pays off before comparing two versions of a response: once both are sorted and indented the same way, Compare text in Text Studio shows only the real differences, line by line.

Why JSON fails to validate

The formatter parses your text before it prints it, so it is a validator too. It follows the JSON standard strictly, exactly as a browser's JSON.parse does. These are the mistakes that trip it most often:

  • A comma after the last item, as in [1, 2, 3,]. JavaScript code allows it; JSON does not.
  • Single quotes around keys or strings. JSON wants double quotes, and every key must be quoted.
  • Comments. // and /* */ are not JSON. Files such as VS Code's settings.json and tsconfig.json use a looser dialect, often called JSONC, that allows them.
  • Curly quotes like “ and ” that crept in through a word processor or a chat app. They look right and are not.
  • Values JSON cannot express: undefined, NaN, Infinity, or a date written as new Date(...).
  • A raw line break or tab inside a string. It has to be written as \n or \t.

The note under the panes starts with "Not valid JSON:" and goes on with the parser's own explanation, which usually names the character it did not expect and where it is. Fix that spot and the result appears at once.

What can change when JSON is reformatted

Formatting is safe for almost everything, but a parser turns the text into values and then writes those values back out. Four details do not survive that round trip exactly as typed:

  • Very long integers. Numbers are read as 64-bit floating point, which is exact only up to 9,007,199,254,740,991. A 20-digit ID such as 12345678901234567890 comes back as 12345678901234567000. Data with IDs like that should keep them as strings.
  • How numbers are spelled. 1.0 comes out as 1, and 1e3 as 1000. The values are equal; the text is not.
  • Repeated keys. If an object has the same key twice, the last one wins and the first disappears without a warning.
  • Escapes. \u00e9 is written back as é, and \/ as /. Both mean the same thing to any JSON reader.

None of this matters for configs and ordinary API responses. It matters when you paste in a database export full of 64-bit IDs and paste the result straight back.

Formatting JSON that should stay private

JSON is what APIs answer with, so the JSON people paste into formatters is often a live response: a user record with an email and a home address, an order with a payment reference, a config file with an API key or a database password in it. Plenty of web formatters do their work in the browser. Others offer to save your JSON or make a link to share it, which means keeping it on a server. From the page alone, it is hard to tell which kind you are on.

The Dev Toolbox has no server to send anything to. The formatter runs inside the Octoolo app on your computer, works with the network unplugged, and forgets the text when you move to another tool. Its neighbors work the same way: JSON to CSV for turning an array into a table, the JWT decoder for tokens found in a response, and Base64 for the encoded fields inside it.

Questions, answered

Is this a JSON validator as well as a formatter?

Yes. Every input is parsed before it is printed, so anything that is not valid JSON gives an error instead of a result. It checks syntax only: it does not test your data against a JSON Schema.

What is the difference between a JSON beautifier and a JSON formatter?

None. Both names mean adding line breaks and indentation so JSON is readable. Minifying is the reverse, and this tool does both.

Does Sort keys change the order of arrays?

No. Arrays keep their order, because in JSON the order of items is part of the data. Only the keys inside objects are sorted, at every level of nesting.

Does minifying JSON change the data?

No. It removes only the spaces and line breaks between values, never anything inside a string, so a program reads the minified and the indented version the same way.

Can I open a .json file?

The formatter works on text you paste or type. Open the file in Notepad or Text Studio, copy its contents into Input, and copy the result back when you are done.

Is my JSON kept anywhere?

No. It lives in the tool while you work and is gone when you switch tools or close Octoolo. Nothing is written to disk or sent over the network.

JSON formatter, and 16 more apps.

Download for Windows

7 days free, then from $3.99 a month for all 17 apps. Windows 10 and 11.