What is JSONL?
A text-based data format where each line is a valid JSON object, widely used for structuring fine-tuning datasets, logging, and streaming data pipelines in AI/ML workflows.
Definition
JSONL (JSON Lines), sometimes called newline-delimited JSON (NDJSON), is a lightweight data format in which each line of a file is a self-contained, valid JSON object terminated by a newline character. Unlike standard JSON, which wraps an entire dataset in a single array, JSONL treats every line independently. This line-oriented structure makes it trivially streamable: a parser can read, validate, and process one record at a time without loading the entire file into memory.
In the context of AI and machine learning, JSONL has become the dominant format for fine-tuning datasets. Each line typically represents a single training example — for instance, an instruction-response pair, a chat conversation with multiple turns, or a classification sample with input text and a label. OpenAI, Mistral, Llama, and most major fine-tuning frameworks accept JSONL as their primary input format, making it a lingua franca for training data.
The format's simplicity is its greatest strength. It requires no schema definition, no special tooling, and no binary parsing — any text editor, scripting language, or Unix command-line tool can create, inspect, and manipulate JSONL files. This low barrier to entry makes it ideal for iterative dataset curation, where data scientists frequently add, remove, filter, and transform training examples.
Why It Matters
The quality of a fine-tuned model is directly proportional to the quality of its training data, and JSONL is the format in which that data lives. Getting JSONL preparation right — consistent schema, clean text, balanced categories, appropriate length distribution — is arguably more important than any hyperparameter choice. A well-structured JSONL file also enables reproducibility: it serves as an auditable record of exactly what the model was trained on, which is critical for compliance in regulated industries. Furthermore, because JSONL files are line-oriented, they integrate naturally with version control (git diffs are meaningful) and data pipelines (streaming ingestion, map-reduce processing).
How It Works
A JSONL file is simply a UTF-8 text file where each line is a complete JSON object. For fine-tuning, a common schema uses three fields: "instruction" (the prompt or question), "input" (optional additional context), and "output" (the desired model response). Chat-style datasets use a "messages" array containing objects with "role" and "content" fields. During fine-tuning, the training framework reads the file line by line, tokenizes each example, and feeds batches to the model. Validation typically involves checking that every line parses as valid JSON, that required fields are present, and that no examples exceed the model's maximum context length.
{"instruction": "What is your return policy?", "output": "We offer a 30-day no-questions-asked return policy for all unused items. Simply initiate a return from your account dashboard and ship the item back with the prepaid label we provide."}
{"instruction": "How do I reset my password?", "output": "Navigate to Settings > Security > Change Password. Enter your current password, then your new password twice. You will receive a confirmation email once the change is saved."}
{"instruction": "Can I upgrade my plan mid-cycle?", "output": "Yes — upgrades take effect immediately. You will be charged a prorated amount for the remainder of the current billing cycle, and the new rate applies from the next cycle onward."}Example Use Case
A customer-support team exports 5,000 resolved tickets from their helpdesk platform, each containing the customer's question and the agent's verified response. A Python script transforms each ticket into a JSONL line with "instruction" and "output" fields, filters out examples shorter than 20 tokens or longer than 2,048 tokens, and deduplicates near-identical entries. The resulting 4,200-line JSONL file is uploaded to Ertas Studio, where it powers a fine-tuning job that produces a model capable of drafting first-response replies matching the team's style and accuracy standards.
Key Takeaways
- JSONL stores one JSON object per line, making it streamable and easy to process incrementally.
- It is the standard input format for fine-tuning datasets across all major LLM frameworks.
- Data quality in the JSONL file is the single largest factor determining fine-tuning success.
- The line-oriented structure plays well with version control, Unix tools, and streaming pipelines.
- Validation — schema checks, length filtering, deduplication — should always be performed before training.
How Ertas Helps
Ertas Studio accepts JSONL as its primary dataset format for fine-tuning jobs. The platform includes a built-in dataset validator that checks schema conformance, flags overly long or short examples, detects duplicates, and provides a quality score before training begins. For teams that do not yet have a JSONL file, Ertas offers dataset templates and conversion utilities that transform CSV, Parquet, and chat-log exports into properly formatted JSONL — lowering the barrier from raw data to a training-ready dataset.
Related Resources
Chat Template
Fine-Tuning
GGUF
Inference
LoRA
Synthetic Data
Tokenizer
Training Data
Getting Started with Ertas: Fine-Tune and Deploy Custom AI Models
Introducing Ertas Studio: A Visual Canvas for Fine-Tuning AI Models
How to Fine-Tune an LLM: The Complete 2026 Guide
Fine-Tune AI Models Without Writing Code
Hugging Face
llama.cpp
Ollama
Ertas for Healthcare
Ertas for SaaS Product Teams
Ertas for Customer Support
Ertas for Data Extraction
Ship AI that runs on your users' devices.
Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.