JSON Lines Format Definition

The formal definition of JSON Lines (JSONL) format: a text format where each line contains exactly one valid JSON object, separated by newline characters.

Formal Definition

JSON Lines (JSONL) is a text format where each line contains exactly one valid JSON object. Lines are separated by newline characters (\n or \r\n), and the file is encoded in UTF-8.

Definition Characteristics

  • • Each line is a complete, valid JSON object
  • • Lines are separated by newline characters
  • • No array wrapping around the file
  • • No trailing commas between lines
  • • UTF-8 encoding is required

Structure Definition

The structure of a JSON Lines file is defined as follows:

example.jsonl
{"id": 1, "name": "Alice", "active": true}
{"id": 2, "name": "Bob", "active": false}
{"id": 3, "name": "Charlie", "active": true}

Each line in the file above is a complete, valid JSON object. The file structure follows this pattern:

  • Line 1: First JSON object
  • Line 2: Second JSON object
  • Line 3: Third JSON object
  • ... and so on

Key Characteristics

The JSON Lines format is defined by these key characteristics:

Format Rules

  • • One JSON object per line
  • • Valid JSON syntax required
  • • Newline character separation
  • • UTF-8 encoding

What's Not Allowed

  • • Array wrapping
  • • Trailing commas
  • • Multi-line JSON objects
  • • Invalid JSON syntax

Comparison with Other Formats

Understanding how JSON Lines differs from other formats helps clarify its definition:

Format Structure Definition
JSON Single object or array One complete JSON structure
JSON Lines Multiple objects, one per line Each line is a complete JSON object
CSV Comma-separated values Tabular data format

Use Cases

Based on its definition, JSON Lines format is ideal for:

  • Streaming large datasets
  • Processing records one at a time
  • Log file storage and analysis
  • Machine learning datasets
  • Real-time data processing

Learn More

For more detailed information about JSON Lines format:

Try Our Tools