INI to JSON
Convert a declared INI subset to JSON while preserving strings and rejecting duplicate keys
INI subset: = / :, single-level [sections], full-line # / ; comments and whitespace-prefixed inline comments. Single-line quoted values are literal; no escapes, interpolation or continuation. Repeated sections are errors. Comments and formatting are not retained.
Input ≤2 MiB; output and name mappings each ≤8 MiB; depth ≤128; values ≤100000; keys or generated paths ≤8192 characters; numeric tokens ≤256 characters. Duplicate keys, collisions, negative zero, non-finite numbers, NUL and unpaired Unicode surrogates are rejected. JSON numbers must round-trip to the same decimal value; integers are limited to ±9007199254740991.
Configuration is processed locally in this page without uploading content or saving input drafts. Analytics exclude keys, values and results. After copying or downloading, check the target application’s configuration rules.
The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.
About this tool
INI to JSON converts a defined, single-level INI subset: section headers, = or : assignments, full-line # and ; comments, and whitespace-prefixed inline comments. Values remain strings by default, preserving 00123, high-precision IDs and quoted whitespace. Optional inference applies only to unquoted strict JSON primitives; quoted values always stay strings. Single-line quotes are literal, without escape interpretation, interpolation or continuation. Duplicate keys, repeated sections and scalar/section collisions stop conversion. Comments and original formatting are discarded. Conversion runs locally in the page without uploading configuration, retaining input drafts, or placing keys and values in analytics. Copy and download contain the complete current result; the screen preview is bounded. Input is limited to 2 MiB, depth to 128, values to 100000, keys or generated paths to 8192 characters, and output and name mappings to 8 MiB each. Numeric tokens are limited to 256 characters. NUL and unpaired Unicode surrogates are rejected.
Scenario Recipes
Migrate a legacy port and account code without changing their meaning
Goal: Keep text identifiers intact and choose numeric inference deliberately.
- Paste the example with code=00123 and a [server] section; leave type inference off.
- Convert and verify that code, port and enabled are strings, including the spaces inside the quoted label.
- Enable inference and convert again: port becomes 8080 and enabled becomes true, while code remains "00123". Add a repeated port line to confirm that the tool refuses the conflict before copying.
Result: A checked JSON config with explicit type choices, preserved leading zeros and no silently overwritten key.
Production Snippets
String defaults versus explicit inference
text
INI input:
code=00123
[server]
port=8080
enabled=true
label=" keep "
Default JSON:
{"code":"00123","server":{"port":"8080","enabled":"true","label":" keep "}}
With inference:
{"code":"00123","server":{"port":8080,"enabled":true,"label":" keep "}}Failure Clinic (Common Pitfalls)
A repeated section or scalar/section name conflict stops conversion
Cause: INI implementations disagree about merging repeated sections. A root db=old and a [db] section cannot both occupy the same JSON key.
Fix: Resolve the duplicate or rename the field in the source. The converter rejects collisions and returns no partial object; do not remove a conflicting value without deciding which setting the application needs.
A configuration expects continuation or escape processing
Cause: This declared subset treats single-line quoted text literally and does not join indented lines or expand references. Other INI readers may interpret the same text differently.
Fix: Convert only the supported subset, keeping paths such as C:\new\test literal. Use the target application’s INI parser when its dialect depends on continuation, interpolation or escaped matching quotes.
Frequently Asked Questions
Which INI grammar is supported?
Single-level [sections], = or : assignments, full-line # / ; comments and whitespace-prefixed inline comments. The first separator divides the key and value. Dots in a section name are literal. INI dialects differ; continuations and interpolation are not implemented.
Why does 00123 remain a string?
Strings are the default. Optional inference recognizes unquoted true, false, null and strict JSON numbers; 00123 is not a strict JSON number. Quoted values always remain strings. Integers outside ±9007199254740991, decimals that would change, overflow, underflow and negative zero are rejected during inference.
What happens to duplicate keys or repeated sections?
Conversion stops without a partial result. Duplicate keys, repeated sections and a root scalar that collides with a section are rejected rather than overwritten. __proto__ and constructor are retained as ordinary own data.
Do quotes preserve whitespace and escapes?
Outer whitespace is trimmed; whitespace inside a matching single or double quote pair is retained. Quoted content is literal: C:\new\test remains backslash text. Only whitespace or a comment may follow the closing quote; multiline values and escaped matching quotes are outside this subset.
Are comments, order and formatting preserved?
Comments and source formatting are discarded. The result represents data, not a reversible INI document. JSON object ordering is not an INI ordering guarantee. A comment-only document produces an empty object; blank input requires configuration text.
Is my configuration saved or uploaded, and are exports complete?
Conversion runs locally in the page without uploading configuration, retaining input drafts, or placing keys and values in analytics. Copy and download contain the complete current result; the screen preview is bounded. Input is limited to 2 MiB, depth to 128, values to 100000, keys or generated paths to 8192 characters, and output and name mappings to 8 MiB each. Numeric tokens are limited to 256 characters. NUL and unpaired Unicode surrogates are rejected.
Keep browsing