DevTools Logo

INI to JSON Converter

INI to JSON Converter

Migrate .ini and .cfg files to nested JSON with visible parse policies.

Runs in your browser
Try an example

INI input

JSON output

No JSON yet

Paste an INI file or load an example.

Examples

Root and sections

Input
app = demo
[server]
host = localhost
Output
{"_root":{"app":"demo"},"server":{"host":"localhost"}}

Root keys are separated from sectioned configuration so no data is silently dropped.

Duplicate collection

Input
[service]
mode = fast
mode = safe
Output
{"service":{"mode":["fast","safe"]}}

The array policy preserves both values and a diagnostic marks line 3 as a duplicate.

Strict typing

Input
[server]
port = 8080
flag = true
code = 007
Output
{"server":{"port":8080,"flag":true,"code":"007"}}

Only unambiguous booleans and numbers are inferred; leading-zero identifiers stay strings.

About this tool

Legacy INI and CFG files are still everywhere, and moving them into JSON-based tooling usually means writing a parser you will throw away. This converter scans the file line by line, turning sections into objects and key-value pairs into properties, while keeping every decision visible in a diagnostics list.

Policies cover the dialect differences that make INI painful: root keys before the first section are collected under _root or rejected; repeated section names merge; duplicate keys can be last-wins, first-wins or collected into an array. Both = and : separators are recognized, BOM and CRLF are normalized, and comment lines starting with ; or # are skipped.

Values stay strings by default, which is the safe behavior for configuration. Turn on type inference for strict booleans and numbers only — 007 deliberately stays a string. Quote stripping and inline-comment stripping are opt-in because INI dialects disagree about both, and every skipped or merged line carries its original line number in the diagnostics panel.

The tool is entirely client-side. INI files frequently hold credentials, so nothing is uploaded, logged or stored; the output is only copied or downloaded when you ask for it.

What this tool does not do

  • This is a pragmatic INI reader, not a full emulation of Windows, systemd or git-config dialects.
  • Dotted section names are normalized as names, not expanded into nested objects.
  • Comments are reported but not preserved in the JSON output; there is no reverse emitter.
  • Files are parsed on the main thread; very large configs can make the tab briefly unresponsive.

How to use this tool

  1. Paste an INI file

    Paste or type your config, or load the application, duplicate-key or malformed-line example.

  2. Set the policies

    Choose duplicate and root-key handling, output formatting, and optional typing, quote stripping and inline-comment stripping.

  3. Read diagnostics

    Every skipped line, merged section and duplicate key is listed with its line number and reason.

  4. Copy the JSON

    Copy the pretty or minified JSON or download it as config.json.

Use cases

Migrating legacy config

Bring old .ini or .cfg settings into a JSON-based configuration loader without hand-transcribing each section.

Auditing config changes

Use the diagnostics list to see every duplicate, merged section and malformed line before a migration.

Building test fixtures

Convert dialect-specific fixtures into JSON for snapshot tests, choosing duplicate and typing policies explicitly.

Policy options

SettingBehavior
Duplicates: last / first / arrayKeep the final value, the initial value, or collect all values into an array.
Root keys: collect / rejectPlace pre-section keys under _root or skip them with a diagnostic.
Type inferencetrue/false and strict numbers are converted; leading-zero values stay strings.
Strip quotesRemove one matching pair of surrounding single or double quotes.
Strip inline commentsRemove a trailing ; or # comment preceded by whitespace (dialect-dependent).
OutputTwo-space pretty JSON or a single minified line.

Both = and : separators are accepted; section names are trimmed and normalized when dotted mode is on.

Common mistakes

Mistake:Assuming all INI dialects treat inline comments the same way.

Fix:Inline comment stripping is off by default. Enable it only when your dialect guarantees that ; and # after whitespace start a comment.

Mistake:Enabling type inference for identifiers with leading zeros.

Fix:The strict numeric regex deliberately leaves 007 and similar values as strings. Use a separate transformation if you need numeric coercion.

Mistake:Confusing INI with TOML.

Fix:INI has no standard type system or nesting rules; this tool exposes decisions as policies. For TOML-specific conversion, use a TOML converter instead.

Frequently asked questions

What happens to keys outside sections?

By default they are collected under a _root object so nothing is lost. Switch the root-key policy to Reject to skip them instead; each skipped line still appears in the diagnostics list with its line number.

How are duplicate keys handled?

Choose last-wins (the default), first-wins, or array collection. All three modes report the duplicate line in diagnostics. Repeated section names are always merged, preserving their original order.

Are ; and # both comments?

At the start of a line, yes — both are skipped. A trailing comment after a value is only removed when Strip inline comments is enabled, because some dialects treat that character as data. Quoted values are respected while scanning for the comment marker.

Are values typed or strings?

Strings by default, which matches the INI convention and protects values such as 007. Turn on type inference to convert exact true/false literals and strictly formatted numbers; leading zeros, scientific notation and anything ambiguous stay strings.

Is my config file uploaded anywhere?

No. Scanning, policy application and JSON emission run entirely in this browser tab. No network request is made and nothing is stored after you leave the page.

References & standards