JSON is everywhere: API responses, config files, log entries, the data your frontend and backend pass back and forth all day. It's also deceptively easy to get subtly wrong in ways that don't show up until something breaks three steps downstream. Here's how to actually read it, validate it, and debug it when it goes sideways.

What JSON is (and isn't)

JSON, JavaScript Object Notation, is a text format for representing structured data: objects (key-value pairs in curly braces), arrays (ordered lists in square brackets), and a small set of primitive types: strings, numbers, booleans, and null.

It is notJavaScript. It looks like a JavaScript object literal, and it's a strict subset of one, but JSON has stricter rules than JavaScript allows: no trailing commas, no comments, no single-quoted strings, and every key must be wrapped in double quotes. Code that's perfectly valid JavaScript can be invalid JSON, and that mismatch is the source of most JSON errors people hit.

The five mistakes that break JSON most often

  1. Trailing commas. {"a": 1, "b": 2,} is invalid, JavaScript tolerates that extra comma; JSON does not.
  2. Single quotes instead of double quotes. {'a': 1} fails. JSON strings and keys must use double quotes, always.
  3. Unquoted keys. {a: 1} is valid JavaScript, invalid JSON. Every key needs quotes.
  4. Comments. JSON has no comment syntax at all, not //, not /* */. If you need comments, you need a different format (or a convention like a _commentkey, which some tools tolerate but isn't part of the spec).
  5. Undefined and functions. JSON has no concept of undefined or functions as values. Only strings, numbers, booleans, objects, arrays, and null.

Formatting vs. validating vs. minifying

These three get used interchangeably, but they're different operations:

  • Formatting (pretty-printing)adds indentation and line breaks so nested structure is readable at a glance. It doesn't change the data.
  • Validatingchecks whether the text is syntactically correct JSON at all, and tells you exactly where it breaks if it isn't.
  • Minifying strips all unnecessary whitespace to make the payload as small as possible, useful for production API responses where every byte over the wire matters, useless for anything a human needs to read.

A good JSON formatterdoes all three: paste raw JSON, get it pretty-printed for reading, minified for shipping, or a clear error message with a line number if it's broken.

A practical debugging workflow

When an API call or config file throws a JSON parse error, work through this order:

  1. Paste the raw text into a validator and look at the exact line/column the error points to, not just the first line of the file. Parsers report where they gave up, which is usually right at or just after the actual mistake.
  2. Check the character right before that position for a stray trailing comma or missing closing bracket, the two most common single-character causes.
  3. If the JSON came from a template or string concatenation (common in server-generated responses), check for an unescaped quote or newline inside a string value, that's the second most common cause and it's invisible until you look for it specifically.
  4. Fix one issue, re-validate, repeat. Multiple errors often cascade from a single missing bracket, so don't assume every reported error is a separate bug.

Converting JSON to and from other formats

JSON doesn't exist in isolation. Two conversions come up constantly:

  • CSV to JSON: turning a spreadsheet export into an array of objects for use in code, using the header row as keys. Watch out for commas inside quoted fields, proper CSV parsing has to respect quoting, not just split on every comma.
  • JSON to CSV: the reverse, useful for getting API data into a spreadsheet. The tricky part is nested objects and arrays, which don't have a native CSV representation and typically get flattened to a JSON string per cell.

Both directions are handled by ToolVyne's CSV to JSON and JSON to CSV converters, which parse properly quoted CSV rather than naively splitting on commas.

The bottom line

Most JSON errors come down to a handful of repeat offenders: trailing commas, wrong quote types, and unescaped characters inside strings. Once you know what to look for, and use a validator that tells you exactly where it broke instead of just saying "invalid JSON," most fixes take seconds, not a debugging session.