How to use the ini file to json converter
- Paste the INI file into the box.
- Choose whether values stay as text or whole numbers, decimals, true, false and null become JSON values.
- Choose what happens to a repeated key: keep the last value or collect all of them into a list. Tick the last box to nest sections whose names contain dots.
- Read the counts of sections and settings, then copy or download the JSON.
Formula
; comment and # comment lines are skipped
[section] starts a section
key = value or key: value, split at the first = or :
An indented line continues the value above it
Settings before the first section go at the top level of the JSON. A setting with no = or : becomes null.
A small settings file
A file with name = Demo and debug = true at the top, a [server] section with host, port and ratio and a [paths] section with root and a two-line list becomes an object with name and debug at the top level and server and paths as nested objects.
With values as text, port is "8080". With numbers, true and false chosen, port is 8080, ratio is 0.75 and debug is true. The list value "first" and "second" on two lines is kept as "first\nsecond".
How INI files are read
INI is an informal format. The rules here follow the common ones: sections in square brackets, settings as a key and a value split at the first equals sign or colon, and comment lines that start with a semicolon or a hash. Spaces around the key and value are trimmed and inline comments are not removed, so a value like 5 ; seconds keeps the note.
A value can continue on the next line if that line is indented more than the setting. The lines are joined with a line break. Keys are case sensitive and keep the case you typed. A section that appears twice is merged, and a key that repeats keeps its last value unless you ask for a list.
Choosing typed values
Everything in an INI file is text, so the safe conversion is to keep strings. Typed mode is a convenience: whole numbers and decimals become JSON numbers, true and false (in any case) become booleans, and null becomes null. A number with a leading zero, such as 007, stays text so that codes and postal codes are not changed. A value in matching quotes loses the quotes.
Check typed output before you rely on it. A version like 1.2 becomes a number, which drops information if the real value is a version string.
Assumptions and limits
- Comment lines start with ; or # as the first non-space character. Inline comments are not removed.
- The key is everything before the first = or :, trimmed. A line without either is a key with a null value.
- Dialects differ, for example in escapes, line continuations and duplicate sections, so check the result against your file.
- Nothing is uploaded. The text stays in your browser and up to 200,000 characters are read.
Frequently asked questions
Why is my number still a string?
Values stay text unless you choose the numbers option. Numbers with leading zeros also stay text on purpose.
What happens to settings above the first section?
They become keys at the top level of the JSON object, next to the section objects.
Are comments kept?
No. Lines starting with ; or # are skipped, because JSON has no comments.
What does nest sections at dots do?
A section named [a.b] becomes an object b inside an object a, instead of a single key called "a.b".