To make JSON data readable, paste it into a formatter and indent it; if it is invalid, go to the position the error message points at; to get it into a spreadsheet, run it through a JSON to CSV converter. Nearly every broken file comes down to four patterns: a trailing comma after the last element, single quotes, an unescaped double quote, or a comment line. An export from an application usually arrives as a single unbroken line of text that cannot be read by eye and achieves nothing when pasted into a spreadsheet. This article takes formatting, validation and conversion in order.
The tools are unremarkable and that is the point. The JSON formatter handles indentation and syntax checking, JSON to CSV moves records into a table, and CSV to JSON goes the other way. When a payload carries encoded binary, the Base64 encoder and decoder opens it, and the URL encoder and decoder makes address fields readable. All of them run in your browser and the data you paste is not sent to the server, which matters when the file holds customer records or configuration.
Formatting JSON data: turning one line into something readable
Indentation changes nothing about the content; it only adds whitespace. The effect is still dramatic. Nesting depth becomes visible, a missing closing brace jumps out, and it stops being a puzzle which field belongs to which object. The JSON formatter indents each level by two spaces, so a line like {"id":7,"name":"Ana","address":{"city":"Leeds"}} becomes a five-line block where every field has its own line and the address object sits one level in.
Payloads traveling to production should stay minified, but anything you are about to inspect deserves a moment of formatting first. The one thing to watch is character encoding. Text containing accented characters looks mangled, with sequences like “é”, when opened under the wrong encoding, and the fault lies with the reader, not the file. Open the same content as UTF-8 and it is fine.
Key order and readability
The order of fields inside an object carries no technical meaning; software produces the same result whatever order they arrive in. For a human reader it matters a great deal. In output you intend to read by eye, putting identifiers first and long text bodies last lets you scan the same content far faster.
Validation: why JSON data breaks
The only reliable way to know whether a file is valid is to run it through a parser; judging by eye is misleading, especially with nested structures. On invalid input, the JSON formatter reports the position where parsing failed. Looking backwards from there beats searching the file at random, because the actual mistake usually sits just before the reported spot. Almost every syntax error falls into one of a few patterns:
- Trailing comma. A comma after the final element, as in
{"a": 1,}, is the most common fault by a wide margin, and in hand-edited files it is nearly the norm.
- Single quotes. Keys and string values require double quotes;
{'a': 1} is invalid.
- Unescaped quotes. A double quote inside a string, written without a backslash, closes the value early; the correct form is
"20\" screen".
- Comments. The format has none. Explanatory lines added to configuration files invalidate them.
- Invisible characters. Text copied out of a web page can carry non-breaking spaces, or a byte order mark at the very start of the file.
If the position in the message does not help, cut the file in half and test which half parses; that finds a fault in a hundred-line file in about seven attempts.
Valid is not the same as correct
Passing a syntax check says nothing about whether the payload contains the fields you expect. A numeric field may have arrived as a string, a required key may be missing, a date may use a different convention. A short list helps when checking by hand: required fields, expected types, and values that must not be empty. To compare two exports, format both the same way and put them side by side in the text diff checker, which works line by line and lists changed lines with their numbers.
Moving records into a table
This is where the mismatch bites. A table is flat: rows and columns. The data structure is a tree, and any field can hold another object or a list. The JSON to CSV converter bridges the gap with a fixed set of rules:
| Shape of the payload | What the converter does | What you should do |
| List of flat objects | Each field becomes a column, each object a row | Nothing |
| Nested object | Sub-fields open into dotted columns such as address.city | Check the column names |
| Array inside a field | Written into the cell as JSON text | Extract it into a second table if you need to analyze it |
| Objects with differing fields | Columns are the union of all fields; gaps stay empty | Interpret the empty cells |
| A single object | Produces a one-row table | Check the source if you expected a list |
A concrete case: the input [{"id":7,"name":"Ana","tags":["a","b"],"address":{"city":"Leeds"}}] becomes a table headed id,name,tags,address.city, and the array lands in its cell as the text ["a","b"]. Because that text contains commas and quotes, the cell is wrapped in double quotes and the inner quotes are doubled, exactly as RFC 4180 prescribes.
Coming back from CSV
In the other direction the converter follows RFC 4180: quoted fields, "" escapes and line breaks inside a cell are all read correctly. The delimiter is detected automatically, with comma, semicolon, tab and pipe supported, so files exported by spreadsheets in locales that use semicolons open without fuss. The first row is treated as the header; if a name appears twice, the second gets _2 appended. Values stay as text: a code like 007 keeps its leading zeros, but if you need arithmetic you have to convert types in your own code. Keeping identifiers and postcodes as strings in the first place ends the type-loss argument before it starts.
Field names and structural discipline
The expensive mistakes in data exchange are not syntactic, they are nominal. When two systems emit the same fact under different key names, the translation layer between them accumulates special cases until nobody dares touch it. The cure is a small dictionary written at the start: every field, its type, its unit, and whether it may be absent.
Three naming rules cover most of it. First, pick one casing convention and hold to it; seeing both customerName and customer_name in one payload is a sign the file passed through two different hands. Second, avoid abbreviations, because a field called ttl becomes a riddle within a week. Third, put the unit in the name: duration_seconds instead of duration prevents an arithmetic bug that would otherwise take an afternoon to find.
On structure, the usual failure is excess depth. An object nested five levels deep does not look organized; it just lengthens every piece of code that reaches into it, and once flattened to CSV it produces unreadable column names like a.b.c.d.e. If getting to a value takes more than three steps, the structure is probably too deep. Finally, absence: a missing field and a field set to null mean different things, and consumers that conflate them produce silent errors. Decide once which is which and write it down.
When the schema changes
Data structures are not frozen; fields get added, renamed and retyped. The problem is never the change itself but a change nobody announced. The safe rule: adding a field is free, removing one or changing its meaning is not. If a field really has to go, add the replacement first, publish both for a while, and remove the old one only once every consumer has moved across.
Small habits that pay off
- Test on a sample. Instead of processing fifty thousand records, try the first hundred. Faults surface in seconds rather than minutes.
- Decode URL fields before reading them. Encoded addresses arrive full of sequences like
%C3%A9. The URL decoder leaves malformed percent sequences untouched and does not turn + into a space, so interpret plus signs from form data accordingly.
- Recognize Base64 fields. Long runs of letters and digits, sometimes ending in
=, are usually Base64. The decoder also accepts the URL-safe variant (with - and _, no padding) and MIME text with line breaks, and warns you when the decoded content is not text.
- Watch the size. An indented file is noticeably heavier than its minified form; strip the whitespace before sending it over a network.
Frequently asked questions
Why does the content look garbled in my browser?
Almost always character encoding. Even when the file was saved correctly, a reader that assumes a different encoding will mangle accented characters. Check the encoding setting where you opened it before editing the file itself.
The format does not allow them. The common workaround is to add the explanation as an ordinary field named something like _note that the consuming software ignores. Inelegant, but it works and keeps the file valid.
How should I handle very large payloads?
Opening hundreds of megabytes in a browser is not reasonable. In that situation, restructure the export so each line holds one independent record. That makes both processing and debugging dramatically easier.
What about embedded binary content?
Binary traveling inside a text format is Base64-encoded, and because every 3 bytes become 4 characters it grows by roughly a third. Decode it before inspecting, and avoid this route for large attachments.
Why does the CSV open as a single column in my spreadsheet?
Spreadsheet programs guess the delimiter, decimal mark and encoding from their locale. The converter writes comma-separated output, so a program set up to expect semicolons may pour every row into one column. Use the import wizard and choose the comma delimiter and UTF-8 encoding explicitly.
When to prefer one format over the other is covered in CSV vs JSON, and the logic behind encoded fields in what is Base64. For the keys and identifiers that end up living in configuration files, see strong passwords and secure identifiers; if the data is destined for a link or a scannable card, the QR code usage guide covers that path.