Trexmi
Developer Ready

JSON Lines Formatter

Validate and normalize JSON Lines or JSONL data as one compact JSON value per line, with strict blank-record detection and an optional final newline.

Validate every non-empty record independently Report the exact invalid line number Normalize each value to compact JSON Reject blank records by default
Strict JSON Lines does not allow blank records. Enable cleanup only when you intentionally want to remove them.
INPUT Developer source value *
0 chars0 words0 lines
Paste the source value for this specific transformation. Example: {"id":1,"name":"Ada"} {"id":2,"name":"Lin"}

Tool settings

Ctrl / ⌘ + Enter
Formatted JSON Lines One compact valid JSON value per line, with an optional final newline.
About the tool

What JSON Lines Formatter does

JSON Lines Formatter checks newline-delimited JSON one record at a time. Each physical line must contain one complete valid JSON value. Objects and arrays are common, but strings, numbers, booleans, and null are valid records too. The output normalizes every record to compact JSON so it remains one value per line.

A blank line is not a JSON value, so strict mode reports it with its source line number. The optional cleanup setting can intentionally remove blank lines from imported logs or hand-edited files. A single trailing line terminator is accepted and can be included in the output.

JSON Lines Formatter validating one JSON value on every line
Validate JSONL line by line without converting the stream into one large JSON array.

How to use

  1. Paste JSON Lines. Put exactly one complete JSON value on each line.
  2. Choose blank-line behavior. Keep strict mode for validation or enable cleanup for a known dirty file.
  3. Choose the final newline. Leave it enabled for conventional JSONL files and command-line processing.
  4. Format the records. The parser validates each line independently and reports the original line number on failure.
  5. Review the result. Confirm record count, value types, and downstream import behavior.
Built for the task

Why use JSON Lines Formatter?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Line-specific validation

Find the exact source line containing invalid JSON instead of receiving one generic document error.

02

Stream-friendly format

Keep each JSON value independent rather than wrapping all records in a large array.

03

Compact normalization

Remove formatting whitespace inside each record while preserving one-record-per-line structure.

04

Strict blank records

Catch invisible empty records unless cleanup is explicitly selected.

Useful answers

Questions about JSON Lines Formatter

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 What is JSON Lines?

JSON Lines is a UTF-8 text format containing one valid JSON value on each line. It is commonly saved as .jsonl and is also called newline-delimited JSON.

02 Is JSONL one valid JSON document?

Usually no. The complete file is a sequence of separate JSON values, so a normal parser expecting one object or array cannot parse the whole file at once.

03 Must every record be an object?

No. An object, array, string, number, boolean, or null can be a record as long as the entire line is one valid JSON value.

04 Are blank lines allowed?

No. A blank line is not a JSON value. Trexmi rejects it by default and offers an explicit cleanup option for non-standard input.

05 Can one JSON record span several lines?

No. Pretty-printed multiline objects break the one-value-per-line rule. Use compact JSON for each record.

06 Should a JSONL file end with a newline?

A final line terminator is strongly recommended because it makes concatenation and command-line processing easier. The formatter can add or omit it.

07 Does the formatter validate that all records share one schema?

No. It validates JSON syntax per line. Different records may have different fields and types unless another schema-validation step enforces consistency.

08 Can this tool process an unlimited log file?

No. The browser and server apply input-size limits. Production streaming pipelines should parse incrementally instead of loading an unlimited file into one request.

Learn JSON

Read the complete JSON Guide

Learn JSON objects, arrays, value types, validation, formatting, parsing, API workflows, and common syntax errors.

  • Objects, arrays, and values
  • Validation and formatting
  • API and parsing workflows
Read guide Practical explanations and examples

Examples

Normalize object records

Whitespace inside each object is normalized while the two independent records remain separate.

Input
{"id":1, "active":true}
{"id":2, "active":false}
Output
{"id":1,"active":true}
{"id":2,"active":false}

Accept any JSON value

JSON Lines permits any complete JSON value, not only objects.

Input
null
42
"ready"
[1,2,3]
Output
null
42
"ready"
[1,2,3]

Locate invalid JSON

A trailing comma makes the second record invalid and the original line number is reported.

Input
{"id":1}
{"id":2,}
{"id":3}
Output
Error: Invalid JSON on line 2: Syntax error

Reject a blank record

Strict mode treats an empty physical line as invalid; cleanup can remove it intentionally.

Input
{"id":1}

{"id":2}
Output
Error: Blank JSON Lines record on line 2.

One JSON value on every line

JSON Lines has three core expectations: UTF-8 text, one valid JSON value per line, and a line terminator between records. A final newline is recommended. The formatter normalizes CRLF or CR line endings to LF and emits each parsed value in compact JSON form.

Do not paste a comma between records and do not wrap the records in an outer array. If the source is one ordinary JSON document, inspect it with JSON Formatter instead.

Blank lines and parser failures

Strict mode reports the first blank record or invalid JSON record with its original line number. A final newline is not treated as an extra blank record. The cleanup checkbox is intentionally opt-in because silently skipping an empty record can conceal a broken exporter.

Use JSON Validator when debugging one ordinary JSON value. For JSONL, fix the reported line in its original file so later line numbers remain meaningful.

Where JSONL is useful

JSONL works well for application logs, model-training examples, event streams, bulk API imports, and command-line pipelines because a consumer can process one record without loading an outer array. Lines can also be appended or concatenated when each producer follows the same encoding and newline rules.

For tabular exports, verify that records share compatible fields before sending them to JSON to CSV. For deeply nested individual records, JSON Flatten can expose their paths.

Limitations and edge cases

The formatter does not validate a shared schema, sort records, remove duplicates, merge multiline stack traces, or stream an unlimited file. JSON numbers are subject to the numeric range and precision of the server parser. A byte-order mark, invalid UTF-8, or literal unescaped line break inside a JSON string can make a record invalid.

Read the JSON Lines format documentation for the line rules and JSON RFC 8259 for the grammar of each value.