Code & data
JSON Lines or a JSON array: identify an export before you repair it
Diagnose an extra-data parse error with two synthetic event records, keep line boundaries meaningful and choose the format your importer actually accepts.
Read the first two complete records
A log export may contain one complete object on each line. Pasting the whole file into a formatter for one JSON document can fail after the first object, even though each individual line parses. That error is useful evidence of a format mismatch. It does not mean the exporter must have lost punctuation.
The JSON Lines convention uses UTF-8 and one valid JSON value per line. A blank line is not a value; a final line terminator is allowed. A JSON array instead has one enclosing pair of brackets and commas between its elements. File extensions help identify a candidate format, but the contents and exporter documentation decide.
JSON Lines:
{"event":"opened","item":"R-7"}
{"event":"saved","item":"R-7"}
One JSON array:
[{"event":"opened","item":"R-7"},{"event":"saved","item":"R-7"}]Distinguish a value from its display lines
For this two-event sample, each object is also one physical line. A string containing the escaped sequence \n does not create another physical record. Conversely, pretty-printing one object across several physical lines breaks the one-value-per-line layout expected by a JSON Lines reader.
Do not use a line counter to determine the number of values in an arbitrary JSON array. An array can occupy one line or many. For a JSON Lines file, count successfully parsed values after checking every record; a raw line count cannot detect an invalid object or a stray blank line in the middle.
One physical JSON Lines record:
{"note":"first line\nsecond line"}
Its note value contains a newline after parsing.Make a tiny sample without truncating a value
Keep the original export. Copy two complete harmless records into a working file and document the expected number of values. KitForma JSON Formatter can inspect each JSON Lines record individually, or inspect the entire array version. It is not a streaming JSON Lines importer and does not automatically wrap multiple objects.
If the receiver accepts only arrays, use a format-aware conversion that parses each line and writes one array. Test that conversion for value types, Unicode and numeric precision. Blindly replacing every line break with a comma can corrupt strings or produce empty elements. Large files need a streaming or bounded-memory workflow appropriate to their size.
- Check the export format in its producing application.
- Select two complete records with no private data.
- Validate each record and confirm the expected count.
- Import the sample using the receiver’s documented format.
- Compare its saved values before handling the full export.
Make the handover self-explanatory
In the delivery note, record the encoding, container format, record count and whether the last line ends with a terminator. Include the tool or script version that performed any conversion. Keep both source and output until the receiving application confirms the expected records.
A conversion that passes a syntax check can still lose meaning. If event order matters, compare the first and last event IDs and at least one record in the middle. If long numeric identifiers are present, preserve their documented representation rather than coercing them to a convenient number type.
Q: Can I just add brackets around a JSON Lines file?
Not by itself. Adjacent values also need separators to form array elements, and the original lines must first be valid records. Use a parser and writer for the chosen format, then compare counts and representative values.
Q: Is a line containing null an empty record?
It is a valid JSON value under the JSON Lines convention, unlike a blank physical line. Your importer may require each value to be an object, so validate that additional contract separately.
KITFORMA
Put it into practice
Reading guides is free and needs no account. Linked tools explain any account or Pro requirements.
Further reading
Sources last reviewed:
KitForma prepared this guide with AI assistance. Examples illustrate a workflow; they are not measurements of real sales, search volume or success. Check the linked sources and the result with your own file.
How to use this guide
Published and maintained by KitForma. The linked references explain the relevant formats and definitions. Examples use sample inputs; they do not establish a speed, quality or compatibility guarantee for your files. Check the tool’s stated limits and inspect your downloaded result.