Skip to content
alpaca.tools

TXT to JSON Converter

Loading TXT to JSON Converter...
5.01 rating61 uses
Your rating for TXT to JSON ConverterYour rating
JSON Tools

About TXT to JSON Converter

Paste text or drop a .txt file and get JSON as you type. The converter detects the shape of the text, whether it is a list of lines, key: value pairs, an .env or INI file, a CSV or TSV table, blank-line separated records, or JSON Lines, and builds the matching array or object. Numbers, true/false and null are typed, repeated keys are collected into arrays, and every adjusted line is listed by line number.

Convert a TXT File to JSON Online

Drop one or more .txt files on the converter, or click Open file. Exports with other text extensions work too: .log, .csv, .tsv, .env, .ini, .properties, .md and .jsonl files are read as plain text. Files up to 50 MB are supported, UTF-8 byte order marks are removed, and Windows line endings are handled.

The output file takes the name of the input, so customers.txt downloads as customers.json. With several files loaded, click a file name to switch between them or download all of them as one JSON object keyed by file name.

Text to JSON: Lines, Key-Value Pairs and Tables

Plain text has no fixed structure, so the converter reads it the way you probably meant it. The detected shape is shown above the text box and can be changed with one click.

  • List of lines: each line becomes one item in a JSON array.
  • Key: value or KEY=value lines: one JSON object, with INI [sections] as nested objects.
  • Table with a header row (comma, tab, semicolon or pipe): an array of objects.
  • Records separated by blank lines: one object per record.
  • JSON or JSON Lines: validated and returned as JSON, one array item per line.
  • Anything else: a single object with the whole text in a text property.

TXT to JSON Array

A list with one item per line, such as product names, email addresses or IDs, becomes a JSON array of strings. Empty lines are skipped and lines starting with #, ; or // are treated as comments, and both behaviors can be switched off under Options.

Numbers in the list are written as JSON numbers, so a column of quantities converts to [12, 4, 30] instead of ["12", "4", "30"]. Leading zeros like 007 and very large IDs are left as strings so nothing is rounded.

Key Value Text to JSON Object

Lines such as name: Ana or PORT=3000 become an object. The separator is the first colon or equals sign on the line, so URLs in values stay intact, and you can set a custom separator such as -> or a tab. Quotes around .env values are removed and the value stays a string.

INI files keep their structure: each [section] becomes a nested object. Turn on Nest dotted keys to turn app.name: Demo into {"app": {"name": "Demo"}}. When a key repeats, all of its values are kept in an array.

CSV and Tab-Separated Text to JSON

When every row splits into the same number of columns, the first row is used as the keys and each following row becomes an object. Quoted fields follow the CSV standard, so commas, doubled quotes and line breaks inside quotes are kept. Empty or repeated headers get unique names like column_3 or name_2.

Choose Object keyed by 1st column under Options to get {"A-100": {...}, "A-101": {...}} instead of an array, which is handy for lookups by ID.

Convert TXT to JSON Lines (JSONL)

Set Output format to JSON Lines to write one compact JSON object per line and download a .jsonl file, the format many data pipelines and log tools import. Going the other way, pasting JSON Lines returns a regular JSON array, and a broken line is reported with its line number.

FAQ