TXT to JSON
Convert plain text into JSON using one of three modes: split each line into a string array, parse delimited rows (with configurable delimiter and optional header detection) into an array of objects, or decode a JSON-encoded string directly. Options to trim whitespace, skip blank lines, and toggle pretty-print give you full control over the output shape. Upload a text file or paste content directly — the entire conversion runs in your browser with nothing sent to a server.
Text
Parse Mode
Options
Output
JSON
What is TXT to JSON Converter?
Plain text files do not come with a schema, but they often contain structure — one item per line, key=value pairs, pipe-separated columns, or consistent delimiters that just happen to use a non-standard separator. This tool makes that implicit structure explicit by converting text into a JSON array or object. Specify a split delimiter (newline, pipe, tab, colon, semicolon, or a custom regex pattern), toggle whitespace trimming and blank line skipping, and decide whether each line becomes a string element or a key-value pair. It is particularly useful for log files with consistent field separators, word lists for autocomplete or spell-checking, address exports from legacy systems, and .env-style configuration files. The output is immediately usable in JavaScript, Python, or any JSON-native pipeline without an additional parsing step.
How to Use
- 1
Paste or Upload Your Text
Paste plain text into the input panel or click "Upload" to load a .txt file. The tool shows the raw content for review — line count, detected delimiter, and encoding are shown before you convert.
- 2
Define Parsing Rules
Choose how lines are split (newline, custom delimiter, or regex pattern), whether to trim leading/trailing whitespace, skip blank lines, and whether to produce a string array or key-value object array.
- 3
Convert to JSON
Click "Convert to JSON". The tool applies your parsing rules and outputs the structured JSON in the right panel with syntax highlighting and a live character/line count.
- 4
Copy or Download
Copy the JSON array or object to use in a script, API call, or data workflow — or download it as a .json file for further processing.
Common Use Cases
Word List & Dictionary Processing
Convert plain text word lists, glossaries, or dictionary files into JSON arrays for use in autocomplete components, spell-checkers, search indexes, or NLP preprocessing pipelines.
Log File Parsing
Parse structured log files with consistent delimiters or patterns into JSON arrays of objects, making log data queryable with jq, loadable into Elasticsearch, or processable in Python.
Address & Contact Import
Convert plain-text address exports or contact lists (one entry per line or delimiter-separated) into JSON arrays for bulk import into CRM systems, mailing list tools, or databases.
Config File Migration
Transform simple key=value plain-text config files into JSON objects for migration to JSON-native configuration systems or for processing by modern application frameworks.
Conversion Examples
Line-per-Item Text → JSON Array
Each non-empty line becomes a string element in a JSON array.
Input JSON
apple banana cherry date elderberry
Output CSV
[ "apple", "banana", "cherry", "date", "elderberry" ]
Key=Value Text → JSON Object
Lines in key=value format are parsed into a flat JSON object.
Input JSON
host=localhost port=5432 dbname=myapp user=admin password=secret
Output CSV
{
"host": "localhost",
"port": "5432",
"dbname": "myapp",
"user": "admin",
"password": "secret"
}