Sean L. YoungStudio tools
Extras

JSON Formatter

Paste JSON from a settings file, an API, or a page's business details (JSON-LD). It's checked as you type, and any mistake is explained in plain English with the exact spot marked. Then tidy it, shrink it onto one line, or explore it as a tree.

What it's for

JSON is a way of writing data as text. On websites you'll meet it in:

  • structured data (JSON-LD): the business details in a page's head that Google reads, such as from the Meta Tag Builder
  • settings files: such as site.webmanifest from the Favicon Maker, or a theme's or plugin's settings
  • APIs and data feeds: answers from online services, and data exported from other tools.

JSON is strict. One missing comma or a curly quote from a word processor breaks the whole thing, and the usual error message ("Unexpected token at position 1432") doesn't help much. The JSON Formatter finds the mistake, says what's wrong in plain English, and can fix the common ones for you.

Quick start

  1. Paste the JSON into the left box, drop a .json file on it, or click Open file….
  2. Read the status. If something's wrong, the message says what and where, and the line is marked.
  3. Fix it, by hand or by ticking Fix common mistakes.
  4. Take the result: tidy or on one line, from the right side. Copy or Download it.

Click Try an example for some JSON with a few mistakes in it on purpose.

Mistakes, explained

The JSON is checked as you type. When there's a mistake, the status under the box explains it, and the line turns red. Click Show me to jump straight to it, or Fix it for me if it's a slip the formatter can fix. Some of the mistakes it explains:

MistakeWhat it says
A missing commaExpected a comma or a } after this value.
A comma after the last itemRemove this extra comma. Nothing comes after it before the }.
Single quotesText must be in double quotes ("…"), not single quotes.
Curly quotesThese are curly "smart" quotes, probably from a word processor. JSON needs plain straight quotes.
A key without quotesPut quotes around the key.
A bracket left openThe JSON ends too early. The { on line 4 is never closed.
Mismatched bracketsThis ] doesn't match the { on line 2. Close it with } instead.
A line break inside textJSON needs the line break written as \n, or the closing quote is missing.
The same key twiceThe key appears twice in the same object. Only the last one counts.

It also explains number mistakes, such as numbers starting with 0 or .5 without a 0, and words JSON doesn't allow, such as True or undefined.

Fixing common mistakes

Tick Fix common mistakes and the formatter fixes the slips it can be sure about, and lists every change it made. It can:

  • straighten curly quotes, and change single quotes to double quotes
  • put quotes around keys, and change = to :
  • add missing commas, and remove extra ones at the end of a list
  • remove comments (JSON doesn't allow them, though many settings files have them)
  • turn line breaks and hidden characters inside text into the proper codes
  • write True, None or undefined the JSON way
  • wrap several separate values in [ ] to make one list.

Your original stays in the left box, unchanged. Read the list of changes, then use the fixed result. Use as input moves it into the left box; Ctrl+Z puts the old version back.

The result

Layout

  • Tidy: one item per line, neatly indented. Choose 2 spaces, 4 spaces or a tab.
  • One line: everything squashed together, with no spaces. Smallest, for sending to a program.
  • Sort keys A–Z: puts every object's keys in alphabetical order, which makes two versions easier to compare.

Copy copies the result, and Download saves it as a .json file.

The tree

Switch to Tree to explore the data as folders you can open and close. Long lists show the first items, with a button to show more. That's the easiest way to find your way around a big API answer.

Click anything in the tree to see its path, such as address.streetAddress or items[3].price. Copy path copies it, ready to use in JavaScript.

Questions

My JSON-LD business details have a mistake in them.

Copy just the part between <script type="application/ld+json"> and </script>, paste it in, and fix it. Or remake it with the Meta Tag Builder.

Is it kept between visits?

Your last JSON stays in this browser until you click Clear, unless it's very large.

Is my JSON sent anywhere?

No. Nothing you paste leaves this browser. That matters for API answers, which can contain private details.