한국어
Home › Guides › Developer

How to find JSON errors and format JSON neatly

Developer · 5 min read

Checking an API response or editing a config file, you will eventually hit an error like "Unexpected token". A long single-line JSON blob is hard to read, too. Knowing a few JSON rules makes most errors quick to find.

JSON basics

The five most common errors

ErrorWrongFixed
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'x'}{"a": "x"}
Unquoted key{a: 1}{"a": 1}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
Unclosed bracket{"list": [1, 2}{"list": [1, 2]}

JavaScript code allows trailing commas and single quotes, so these errors show up a lot when you paste code into a JSON file.

Finding the error fast

  1. Paste your JSON into the formatter below.
  2. If the syntax is wrong, it shows the line, the column and the likely cause.
  3. Look just before the reported spot first. A missing comma or quote is often one step earlier than where the parser gives up.
  4. Fix it and format again to get properly indented JSON.
JSON FormatterPretty print, error position, CSV
Open tool

Pretty print or minify

Converting between JSON and CSV

An array of objects can be turned into CSV and opened in Excel or Google Sheets, and CSV can be turned back into a JSON array. Nested arrays or objects end up as text in a single cell.

Safe for sensitive data

JSON often contains API keys or user data. This tool processes everything in your browser, so what you paste is never sent to a server.

Tools in this article

JSON FormatterPretty print, error position, CSV
Open tool