JSON Toolbox LogoJSONToolbox

TXT to JSON Converter

Convert plain text, TXT files, line lists, key-value text, and delimited records into JSON. Pick one of three parsing modes, review the live preview and warnings, then copy or download the result.

Parsed Preview
Enter text to preview the parsed result
Converted JSON will appear here...
All processing happens in your browser. No JSON is sent to our servers.

Key Features

TXT and Plain Text Input

Paste plain text into the editor or open a local .txt, .csv, .tsv, .text, or .log file. The file is read in your browser and never uploaded.

Lines to JSON Array

Turn one item per line into a JSON array, in the original input order. Empty lines can be skipped and duplicate values can be removed while keeping the position of the first occurrence.

Key-Value Text to Object

Parse lines such as name: Alice or name=Alice into a JSON object. The line is split at the first separator only, so url: https://example.com/a:b keeps the full URL as its value.

Delimited Text to Records

Convert comma-, tab-, semicolon-, or pipe-separated text into a JSON array of objects, with auto-detection available. Use the first row as headers, or let the tool name the columns column_1, column_2, and so on.

Preview and Parsing Warnings

Review the first 10 parsed lines, key-value entries, or data rows before exporting. Duplicate keys, skipped lines, and rows with a different number of columns are reported in the preview.

Optional Type Inference

When enabled, lowercase true and false become booleans and plain integers or decimals such as 30 or 1.5 become numbers. It is off by default, so values such as 00123, 1.10, TRUE, and NULL stay strings.

Copy JSON Output

Copy the generated JSON to the clipboard for use in scripts, APIs, configuration files, test fixtures, or frontend applications. The copy always contains every parsed item, not just the previewed ones.

Download JSON File

Download the full result as a .json file after reviewing the parsed structure and warnings.

Browser-Based Processing

Text parsing and JSON generation happen in your browser. No account is required and the input text is not sent to a remote conversion service.

How to Use

1

Paste or open text

Paste plain text into the input editor or open a local .txt file. The input can be a line list, key-value text, or a delimited table.

2

Choose a parsing mode

Select Lines to JSON array for one item per line, Key-value text to object for key/value records, or Delimited text to objects for table-like data. Loading a built-in example switches the mode for you.

3

Configure parsing rules

The available options depend on the mode: the delimiter and header switch appear in delimited mode, the key separator appears in key-value mode, and skip empty lines and remove duplicate lines apply to line and key-value text. Type inference, empty-value, trim, and indent options are always available.

4

Review the preview

Check the detected lines, keys, rows, and columns together with any duplicate-key, skipped-line, or uneven-row warnings before creating the final JSON.

5

Convert and export

Click Convert to JSON, then copy the result or download it as a .json file. The output also updates automatically while you type, so you can adjust the options and watch the result change. Validate the output before sending it to another system.

Convert Delimited Text to JSON

A small comma-separated table with a header row, converted into an array of JSON objects.

Delimited Text
name,age,city
Alice,30,New York
Bob,25,London

Comma-separated text whose first line is the header row.

JSON Array
[
  {
    "name": "Alice",
    "age": 30,
    "city": "New York"
  },
  {
    "name": "Bob",
    "age": 25,
    "city": "London"
  }
]

Shown with Infer basic types enabled. The option is off by default, so 30 and 25 remain the strings "30" and "25" unless you turn it on.

Indent is set to 2 spaces in this example. The downloaded file always contains every parsed row, even when the preview shows only the first 10.

How to Convert TXT and Plain Text to JSON

What Is TXT to JSON Conversion?

TXT to JSON conversion turns unstructured or semi-structured text into a JSON object or array. Unlike a fixed file-format conversion, plain text does not define one universal structure, so the converter has to apply explicit parsing rules.

A line list, a key-value file, and a CSV-like table are all text, but they should produce different JSON shapes. Choosing the correct parsing mode matters more than changing the file extension.

Choose the Right Parsing Mode

  • Lines to array: use when each non-empty line is one string value.
  • Key-value text: use when each line holds a key and a value separated by a colon or an equals sign.
  • Delimited rows: use when the text has columns separated by commas, tabs, semicolons, or pipes.

Convert Lines to a JSON Array

Input:

Alice
Bob
Charlie

Output:

["Alice", "Bob", "Charlie"]

This mode suits lists of IDs, URLs, emails, tags, and keywords. The array keeps the input order, and Remove duplicate lines drops later duplicates while keeping the first occurrence in place.

Convert Key-Value Text to a JSON Object

Input:

name: Alice
age: 30
active: true

Output with Infer basic types enabled:

{
  "name": "Alice",
  "age": 30,
  "active": true
}

With the option off, which is the default, the output is:

{
  "name": "Alice",
  "age": "30",
  "active": "true"
}

Key-value parsing splits each line at the first separator only. A line such as url: https://example.com/a:b yields the key url and the value https://example.com/a:b, rather than breaking the URL apart. Lines with no separator, or with an empty key, are skipped and counted in the preview instead of failing the conversion.

Convert Delimited Text to JSON Records

Input:

name,age,city
Alice,30,New York
Bob,25,London

Output:

[
  {"name":"Alice","age":"30","city":"New York"},
  {"name":"Bob","age":"25","city":"London"}
]

Use a CSV-compatible parser when fields can contain delimiters, escaped quotes, or line breaks. In delimited mode, quoted fields are supported: a value wrapped in double quotes may contain the delimiter and line breaks, and two consecutive double quotes inside it represent one literal quote. A simple split on the delimiter is not sufficient for that kind of data.

Type Inference Can Change Values

Plain text carries no reliable type system. This converter only infers a narrow set of values, and only when Infer basic types is enabled: lowercase true and false become booleans, and plain integers or decimals matching -?\d+ or -?\d+\.\d+ become numbers.

  • Leading zeros: 00123 stays the string "00123".
  • Version strings: 1.10 would lose its trailing zero as a number, so it stays text when inference is off.
  • Uppercase and null-like text: TRUE, FALSE, and NULL are not recognized and stay strings.
  • Scientific notation: 1e5 is not recognized and stays a string.
  • Dates and postal codes: these are treated as text unless you enable inference and they happen to match the numeric patterns.

Keep type inference disabled when preserving the exact source text matters more than convenience.

Headers and Uneven Rows

Delimited input may contain a header row, missing values, extra values, or blank headers. When First row is header is off, or a header cell is blank, the converter generates the names column_1, column_2, and so on. Rows with a different number of columns are highlighted in the preview and reported as a warning; the conversion still runs, missing cells become empty values, and extra values beyond the column count are ignored.

Text to JSON Is Not Natural-Language Understanding

Plain text can be ambiguous. A paragraph, a log file, a Markdown document, or an AI response cannot become a meaningful JSON structure without rules. Use an explicit pattern such as one item per line, key-value pairs, or a consistent delimiter. For AI-generated output, first make sure it follows a predictable structure.

TXT to JSON vs JSON String Parsing

TXT to JSON can mean several things. This page handles structured plain text and text files. If the input is already a JSON-encoded string such as "{\"name\":\"Alice\"}", use a JSON unescape workflow instead. If the input is an ordinary JSON document, use a JSON formatter or validator rather than a text converter.

TXT to JSON vs JSONL

A JSON array stores many values inside one JSON document. JSON Lines stores one JSON value per line. This page outputs a JSON array or a JSON object and does not provide a JSONL output mode, so if a downstream system needs JSONL, convert it with a separate step.

Privacy and Browser-Based Processing

This converter reads text and generates JSON in the browser rather than uploading the input to a remote service. That is useful for internal lists and development data, but it is not a secret-management system. Avoid entering credentials, tokens, private customer records, or confidential production text into any online tool.

When to Use a Local Parser

For very large files, repeatable data pipelines, strict CSV compatibility, confidential data, or automated processing, use a local parser or command-line workflow. Browser conversion is best suited to quick transformations, inspection, and small-to-medium inputs.

Related Tools

JSON Editor
Edit, validate, format, and minify JSON online in your browser. Paste or open a JSON file, make changes in a syntax-highlighted editor, and copy or download the result without an account.
CSV to JSON Converter
Convert CSV, TSV, or delimited text into JSON online in your browser. Paste data or open a file, choose the delimiter and header behavior, preview the parsed rows, and export an array of JSON objects with optional type inference.
JSON to Text Converter
Turn JSON into readable plain text in your browser. Extract flattened paths, key-value lines, keys, values, or JSON Lines from valid JSON, then copy or download the result as a .txt file.
JSON Schema Validator
Validate JSON data against a JSON Schema. This online JSON Schema validator lets you validate JSON against schema, check structure, data types, required fields, and constraints, and get detailed error messages — all in your browser.
Large JSON Viewer
Open large JSON and NDJSON files in your browser and search them locally. Read-only viewing with line numbers, full-text search by key, value or path, jump-to-match, and exports — no upload.
JSON to CSV Converter
Convert JSON records to CSV online for Excel, Google Sheets, and other spreadsheet tools. Paste JSON or open a file, preview the detected columns, optionally flatten nested objects, and download a CSV file directly from your browser.
JSON to Table Converter
Convert a JSON array of objects into a readable table online. This JSON to table converter detects columns automatically, reports row and column counts, flattens nested objects when needed, and exports the data as CSV.
JSON Schema Generator
Generate a JSON Schema draft from representative JSON data. This JSON Schema generator infers object structure, arrays, basic data types, and selected string formats, then lets you review, copy, or download the generated schema for validation, API documentation, and development workflows.
JSON to TypeScript Converter
Generate TypeScript interfaces or type aliases from JSON data online. The converter infers objects, arrays, primitive types, nullable values, and nested structures, then produces editable TypeScript declarations that you can copy or download for API responses, configuration data, and frontend projects.
JSONC to JSON Converter
Convert JSONC or JSON with comments into standard JSON. Remove line comments, block comments, and trailing commas without touching comment-like text inside strings, then validate, format, copy, or download the result.

Frequently Asked Questions

What does this TXT to JSON converter do?

It converts plain text into JSON using a parsing mode you choose. Lines to JSON array turns one item per line into a JSON array, Key-value text to object turns key/value lines into a single JSON object, and Delimited text to objects turns table-like text into an array of JSON objects.

Can I convert a TXT file to JSON?

Yes. Open a .txt, .csv, .tsv, .text, or .log file from your device, or paste its contents. Then choose the parsing mode that matches the file, review the preview, and copy or download the generated JSON.

How do I convert a list of lines to a JSON array?

Choose Lines to JSON array and paste one value per line. Three lines containing Alice, Bob, and Charlie become ["Alice", "Bob", "Charlie"]. The array keeps the original input order.

Can I convert key-value text to JSON?

Yes. Choose Key-value text to object and use lines such as name: Alice or name=Alice. The line is split at the first separator only, so a line such as url: https://example.com/a:b produces the key url with the full URL as its value.

Which key separators are supported?

Colon (:) and equals (=). Select the one that matches your input. Lines without the selected separator are skipped and counted in the preview instead of failing the whole conversion.

Can I convert CSV-like text to JSON?

Yes. Choose Delimited text to objects, select the delimiter, and indicate whether the first row contains headers. Each data row becomes one JSON object.

Which delimiters are supported?

Comma, tab, semicolon, and pipe, plus auto-detection. Auto-detection scores each candidate by how consistently it splits the first rows into the same number of columns, so choose the delimiter manually when the input is ambiguous or when a delimiter also appears inside values.

Does it support quoted values?

Yes in delimited mode. A field wrapped in double quotes may contain the delimiter and line breaks, and two consecutive double quotes inside a quoted field represent one literal double quote.

Can I convert text without a header row?

Yes. Turn off First row is header and the converter names the columns column_1, column_2, column_3, and so on. A blank cell inside a header row falls back to the same generated name.

Does it infer numbers and booleans?

Only when Infer basic types is enabled, and only for a narrow set of values: lowercase true and false become booleans, and plain integers or decimals such as 30, -7, or 1.5 become numbers. Values such as TRUE, NULL, 1e5, .5, +5, 00123, 1.10, and 2026-09-18 stay strings. Keep the option off when identifiers, postal codes, version strings, or formatted values must remain text.

What happens to empty lines and empty values?

In line and key-value mode, Skip empty lines is on by default and removes blank lines. Empty values become empty strings, or null when Convert empty values to null is enabled. In delimited mode, blank lines are dropped by the parser and missing cells become empty values.

What happens when duplicate keys appear?

The converter reports how many duplicate keys were found and keeps the last value for that key. The key itself stays at the position of its first appearance, because a JSON object cannot hold two separate properties with the same name.

Can I remove duplicate lines?

Yes. In Lines to JSON array mode, turn on Remove duplicate lines. The first occurrence keeps its position and later duplicates are dropped, so the remaining order still follows the input.

Can I convert indented text to nested JSON?

No. Indented or hierarchy text is not supported because indentation rules are ambiguous. Flatten the text into one item per line, key-value pairs, or delimited rows, and then convert it.

Can I convert ChatGPT or AI-generated text to JSON?

Only when the text follows a recognizable structure such as one item per line, key-value pairs, or a consistent delimiter. This page is not a natural-language parser and does not guess field names or schemas from prose.

Can I convert text to JSON Lines?

No. This page outputs a JSON array for line and delimited input, or a JSON object for key-value input. There is no JSONL output mode.

Does the preview limit the exported JSON?

No. The preview shows the first 10 parsed lines, key-value entries, or data rows so you can check the parsing rules quickly. Copy and download always use every parsed item.

Can I convert a large TXT file?

The practical limit depends on file size, number of lines, browser memory, parsing mode, and preview rendering. Very large files may be slow to render in the editor, in which case a local parser or command-line tool is a better fit.

Is my text uploaded to a server?

No. The page reads the input and generates JSON in your browser. You should still avoid entering passwords, access tokens, private customer data, or confidential production text into any browser-based tool.

Is this a free TXT to JSON converter?

Yes. You can paste or open text, choose a parsing mode, review the output, and copy or download JSON without creating an account.