Merge JSONL Files Online

Merge JSONL and NDJSON files into one, with every line checked, duplicates removed and nothing uploaded.

Combine JSONL Files Into One Clean File

Every line is checked

Each line is parsed as JSON. Invalid lines are reported with the file name, the line number and the parser message, and one bad file does not stop the others.

Duplicates removed your way

Drop exact duplicate records, or records that share a key such as id or user.email, and keep either the first or the last occurrence.

Records stay as they were

Valid lines are written with their original text by default, so large numbers, key order and spacing inside a record do not change.

How to Merge JSONL Files

Your original files stay unchanged; the merged file is a new download.

1

Add your JSONL files

Choose or drop .jsonl, .ndjson, .jl, .json or .txt files, paste text, or try the sample files.

2

Check each file and set the order

Each file shows its lines, valid records and invalid lines. Reorder with the arrows or by dragging.

3

Choose the merge settings

Decide what happens to invalid lines, remove duplicates, sort, and pick JSONL or JSON array output.

4

Merge and download

The output is re-read and checked, then offered as a download with a preview and a report.

Merging regular JSON files that hold arrays or nested objects is a different job. Use the JSON merger for that, or read how to merge JSON files.

Merge Settings Explained

Invalid lines
Skip and report leaves out lines that are not valid JSON and lists them by file and line number. Stop the merge produces nothing and names the first bad file and line.
Remove duplicates
Off, Exact duplicate records (key order is ignored), or By key with a path such as id or user.email. Keep the first or the last occurrence. Records without the key are always kept.
Sort
Keep file order, or sort by a key path, ascending or descending. Numbers compare as numbers and text alphabetically. Records without the key go last, and ties keep file order.
Add source file
Adds a field (default _source) holding the original filename to every object record. Records that are arrays, strings or numbers are left unchanged and counted in a note.
Keep original text
Writes each valid line exactly as it was in the input, minus surrounding spaces. It is on by default and is not available with Add source file or JSON array output.
Output format
JSONL writes one record per line. JSON array writes one array with every record, indented with 2 spaces, for programs that do not read JSONL.
Line ending
LF by default. CRLF is there for Windows programs that need it. JSONL output always ends with a final line break.
Output filename
Defaults to merged. The extension follows the format: .jsonl for JSONL and .json for a JSON array.

Are My Files Uploaded?

No. Your browser reads each file, checks every line, and builds the merged file on your device. There is no upload and no account, and nothing is kept after you close the page. That matters for logs, exports and training data that contain personal or internal information.

Will Merging Change My Records?

Not with Keep original text on, which is the default for JSONL output. Each valid line is copied as it was, minus surrounding spaces. If you add a source field, choose JSON array output or turn the option off, records are parsed and written again as compact JSON. The data stays the same with one exception: integers beyond JavaScript's safe range (above 9,007,199,254,740,991) can be rounded, and keys that are whole numbers move to the front of their object. The tool warns you when an input has an integer with more than 15 digits.

Frequently Asked Questions

Complete Guide to Merging JSONL Files

What JSON Lines Is and Where It Is Used

JSON Lines, written JSONL, is a text format with one JSON value per line. The rules on jsonlines.org are short: the file is UTF-8, each line is a complete JSON value as defined by RFC 8259, and lines end with a line feed. NDJSON, described in the NDJSON specification, is the same format under another name. The extensions .jsonl, .ndjson and .jl all mean the same thing.

The format is common wherever records arrive over time or files get large:

  • Logs. Structured loggers write one JSON object per event, and log shippers rotate the output into hourly or daily files.
  • Data exports. Databases, data warehouses and analytics products export tables as JSONL, often split into numbered parts.
  • Model training files. Fine-tuning datasets, evaluation sets and batch request files hold one example or request per line.

In each case you end up with many files that belong together, and at some point you need to merge the JSONL files into one. If you want to look at a file before or after merging, open it in the JSONL Viewer. If you need test data, the sample JSONL files page has twelve ready-made files, including one with duplicates and one with invalid lines. The sample JSON files page has JSON files that the JSON to JSONL converter turns into JSON Lines.

Why Plain Concatenation Sometimes Fails

Because every line stands alone, you can merge JSONL files by writing one after another. There is no array to rebuild and no commas to fix. That only holds when each file is clean. These five problems cause most broken merges:

  • Missing final line break. If a file ends without one, its last record and the first record of the next file land on the same line. That line is no longer valid JSON.
  • Byte order mark. Files saved by some Windows programs start with a BOM. After concatenation the BOM sits in the middle of the merged file, in front of a record, and strict parsers reject that line.
  • CRLF line endings. Mixing Windows and Unix line endings usually parses, but it produces noisy diffs and trips tools that compare lines as text.
  • A stray JSON array file. One export in the set is a regular .json array. Its lines are fragments such as [ and {"id": 1},, and none of them is a record.
  • Blank lines. Empty lines between records are harmless to some readers and an error to others.

The JSONL Merger handles all five. It treats the end of a file as the end of a line, removes byte order marks, accepts LF, CRLF and CR, converts a file that is one JSON array into one record per item, and ignores blank lines.

Merging JSONL Files From the Command Line

cat and awk on Linux and macOS

cat is the usual way to concatenate JSONL files. It copies bytes and checks nothing, so it is fast and works on files of any size. Use awk 1 when you are not sure that every file ends with a line break.

Bashterminal
# Fine when every file ends with a line break
cat part1.jsonl part2.jsonl part3.jsonl > merged.jsonl

# Safer: awk adds the missing line break at the end of a file
awk 1 part1.jsonl part2.jsonl part3.jsonl > merged.jsonl

# Every .jsonl file in a folder, in name order.
# Write the result outside that folder so it is not read as input.
awk 1 logs/*.jsonl > merged.jsonl

Get-Content in PowerShell

Get-Content reads lines, so a missing final line break is not a problem, and it drops a byte order mark while reading. Do not use the > redirect in Windows PowerShell 5.1: it writes UTF-16, which most JSONL readers cannot open.

PowerShellmerge.ps1
# Reads line by line, drops blank lines, writes UTF-8.
# PowerShell 7 writes no byte order mark; Windows PowerShell 5.1 adds one.
Get-Content part1.jsonl, part2.jsonl, part3.jsonl -Encoding utf8 |
  Where-Object { $_.Trim() } |
  Set-Content merged.jsonl -Encoding utf8

jq -c

jq parses every record, so it validates while it merges, and -c writes each record on one line. It also fixes pretty-printed input. It has two limits. It stops at the first invalid line instead of skipping it. And the -s (slurp) option, which duplicate removal and sorting need, loads every record into memory. Versions before 1.7 also read numbers as 64-bit floats, so very large integers are rounded. The jq manual documents each option.

Bash (jq)terminal
# Parse every record and write it back on one line
jq -c . part1.jsonl part2.jsonl > merged.jsonl

# Turn a JSON array file into JSONL before merging it
jq -c '.[]' export.json > export.jsonl

# Merge and keep one record for each id (output is sorted by id)
jq -c -s 'unique_by(.id)[]' part1.jsonl part2.jsonl > merged.jsonl

# Sort a merged file by a field
jq -c -s 'sort_by(.created_at)[]' merged.jsonl > sorted.jsonl

A short Python script

A script is the right choice when you want to skip bad lines and keep going. This one reads the files line by line, so memory use stays low. It reports invalid lines with their line numbers, removes duplicate id values and writes the original text of each line. For more on reading JSON in Python, see how to parse JSON in Python.

Pythonmerge_jsonl.py
import json
import sys

inputs = ["part1.jsonl", "part2.jsonl", "part3.jsonl"]
seen = set()
written = duplicates = skipped = 0

with open("merged.jsonl", "w", encoding="utf-8", newline="\n") as out:
    for path in inputs:
        # utf-8-sig drops a byte order mark if the file has one
        with open(path, encoding="utf-8-sig") as src:
            for line_no, line in enumerate(src, start=1):
                line = line.strip()
                if not line:
                    continue
                try:
                    record = json.loads(line)
                except json.JSONDecodeError as err:
                    print(f"{path}:{line_no}: {err}", file=sys.stderr)
                    skipped += 1
                    continue
                key = record.get("id") if isinstance(record, dict) else None
                if isinstance(key, (str, int)):
                    if key in seen:
                        duplicates += 1
                        continue
                    seen.add(key)
                out.write(line + "\n")  # the original text, unchanged
                written += 1

print(f"{written} written, {duplicates} duplicates, {skipped} invalid", file=sys.stderr)

The command line is enough when the files are clean and you only need them joined. The browser tool saves time when you want a per-file report of bad lines, duplicate removal by key, a source field on each record, or when you are on a computer where you cannot install jq or Python.

When to Remove Duplicates and How to Choose a Key

Duplicates appear when exports overlap (a daily file and a weekly file that cover the same day), when a job is retried and writes its output twice, or when the same file is added to a merge under two names. Whether to remove them depends on what a record means. Two identical log events can both be real. Two rows with the same user id usually are not.

  • Exact duplicate records is the safe choice when you have no stable id. It only removes records whose whole content matches. Key order does not matter, so {"a":1,"b":2} and {"b":2,"a":1} are the same record.
  • By key fits records with a stable identifier, such as id, custom_id, uuid or a nested path like user.email. Pick a key that is unique for each real-world item. A timestamp is rarely a good key.
  • Keep first or keep last. If later files hold newer versions of a record, put the files in date order and keep the last occurrence. If the first file is the trusted source, keep the first.

The number 1 and the text "1" are different key values, so ids stored as numbers in one file and as strings in another will not match. Records that lack the key are never removed.

Sorting the Merged File

File order is the right default for logs and time-ordered exports, as long as you list the files in order. Sort by key when the files overlap in time or when a later step expects ordered input, for example sorting by created_at or id. ISO 8601 timestamps such as 2026-03-14T09:30:00Z sort correctly as text. Numbers are compared as numbers, so 9 comes before 10. Records without the key are placed at the end, and records with equal keys keep their file order.

Checking the Result

Before the download appears, the tool reads its own output again. For JSONL it parses every line and confirms that the line count equals the record count. For a JSON array it parses the whole text and checks the array length. You can run the same check yourself on any merged file:

Bashterminal
# Count the records
wc -l merged.jsonl

# Confirm that every line parses (prints OK, or the first error)
jq -c . merged.jsonl > /dev/null && echo OK

The number of records should equal the sum of the valid records in each input, minus the duplicates removed. The result panel shows each of those numbers. To read the merged data as rows and columns, convert it with JSONL to JSON and open the array in JSON to Table or JSON to Excel. Records with nested objects fit a table better after the JSON Flattener.

Troubleshooting Common Errors

ProblemCauseFix
One line holds two records: {"id": 3}{"id": 4}A file did not end with a line break, so cat joined its last line to the first line of the next file.Merge with awk 1 or with this tool. Both treat the end of a file as the end of a line.
The first line of the second file is invalid, but it looks fineThe file starts with a byte order mark, which is invisible in most editors.Read with utf-8-sig in Python, or merge here. The tool removes byte order marks, including ones in the middle of a file that was built with cat.
Every line of one file is invalidThe file is a pretty-printed JSON array or object, or it was saved as UTF-16 without a byte order mark.A single array or object is detected here and converted. For several pretty-printed objects in a row, run jq -c . first.
"Unexpected token" on lines that end with a commaThe lines were copied out of a JSON array, so each record still has its trailing comma.Remove the commas, or put [ and ] around the text so it is a real array.
An id such as 9007199254740993 comes out as 9007199254740992A tool parsed the number as a 64-bit float and wrote it back.Copy lines as text. Here, leave Keep original text on. In scripts, write the original line, not the parsed value.
Fewer records than expected after mergingDuplicate removal matched more than you meant, for example a key that repeats across unrelated record types.Check the Duplicates removed count, then switch to a more specific key or to Exact duplicate records.

If a merged file is too large for the program that has to read it, cut it back into parts. JSONL can be split on any line break without breaking a record; see how to split JSON files or use the JSON File Splitter. To find the exact line that an import job complained about in a very large file, the Large Text File Viewer can jump to a line number without loading the whole file. More converters and editors are listed on the JSON tools page.

Continue working with your JSONL file

Inspect the merged records, convert them to a JSON array, or explore more JSON tools.