Multiple JSON Objects – Fix Concatenated JSON or Use JSONL

Local only

Standard JSON contains one top-level value. Two objects concatenated together are not one valid JSON document even when each object is valid on its own.

Indent

17 chars · 2 lines

Two-way sync · Edit either side and the other updates automatically.

Invalid JSONUnexpected content after the JSON value
Line 2Column 1Character 10Found “{”
{"id":2}

JSON document structure

Why two valid JSON objects can still make one invalid document

A parser finishes after the first root object and then encounters another non-whitespace token. If the source intentionally emits one JSON value per line, it is JSONL/NDJSON and should be processed with a line-oriented parser instead. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Browser-local JSON processing
  • Route-specific malformed JSON example
  • Focused parser or repair guidance
  • Broken and corrected JSON example
  • Related JSON problem navigation

Steps

  1. Confirm that parsing succeeds for each object independently.
  2. Identify whether the source format is a stream/JSONL format or was accidentally concatenated.
  3. Wrap values in an array only when a single array is the intended data model; otherwise split or use JSONL tooling.

Standard JSON has exactly one root value

The root can be an object, array, string, number, boolean, or null, but once that value finishes only whitespace may follow. Another { starts a second document rather than extending the first.

  • Application logs append one JSON object per line.
  • Two API responses are copied into one editor buffer.
  • Streaming producers emit consecutive records without an array wrapper.

JSONL is often the correct format for record streams

JSONL keeps each line independently parseable and avoids loading a huge top-level array. If the source is intentionally record-oriented, use a JSONL parser rather than rewriting every stream into standard JSON.

Multiple top-level objects example

The two objects are valid separately but invalid as one standard JSON document. An array is one possible combined representation.

Concatenated JSON objects

{"id":1}
{"id":2}

Single JSON array

[
  {"id":1},
  {"id":2}
]

Common questions

Frequently asked questions

Can JSON contain multiple root objects?

No. Standard JSON contains one root value. Additional non-whitespace content after that value makes the document invalid.

Is one JSON object per line valid JSON?

Not as one standard JSON document. It is commonly treated as JSONL or NDJSON, where each line is parsed independently.

Should I wrap multiple objects in an array?

Only when the consumer expects one collection. For streaming or log data, JSONL may be the better representation.

Debugging a specific JSON issue? Browse JSON troubleshooting.