Xerobit

INI to JSON Converter

Paste your INI configuration text to convert it to valid JSON. The converter handles sections, global keys, comments, and quoted values, reporting the exact line number of any syntax error. It runs entirely in your browser so nothing is uploaded to a server.

Paste your INI content here.

JSON

{}

How to use the ini to json converter

  1. Paste or type your INI configuration into the text area.
  2. The JSON output updates automatically as you type.
  3. If there is a syntax error, the exact line number and issue are shown.
  4. Copy the resulting JSON for use in your application.

How the INI format maps to JSON

The INI format organizes data into global key-value pairs and named sections. When converting ini to json, global keys become top-level properties in the JSON object. Each section header, denoted by square brackets like [database], becomes a nested JSON object containing the keys defined under it.

For example, this INI text:

[server]
host = 127.0.0.1
port = 8080

Produces this JSON:

{
  "server": {
    "host": "127.0.0.1",
    "port": 8080
  }
}

The converter parses each line sequentially. Blank lines and lines starting with ; or # are treated as comments and ignored. Keys and values are split on the first = character, and surrounding whitespace is trimmed from both sides.

Value types and parsing rules

INI files store everything as text, but JSON supports distinct types. This converter infers types automatically to produce clean JSON output. A number is only converted when it prints back exactly as typed, so values like 1.10 or very long ids stay as text. The following rules apply to every value parsed during the ini to json conversion:

INI ValueJSON TypeResult
42 or -3.14Number42, -3.14
true or falseBooleantrue, false
nullNullnull
"hello" or 'world'String"hello", "world"
anything elseString"anything else"

Quoted strings have their outer quotes removed, which is useful when a value contains leading spaces or characters that might otherwise be misinterpreted. Unquoted numeric strings that match standard integer or decimal patterns are converted to JSON numbers. Boolean and null checks are case-insensitive.

Common mistakes in INI files

When converting ini to json, syntax errors in the source file will prevent a valid conversion. The most frequent issues include missing closing brackets on section headers, such as [section instead of [section]. The converter reports the exact line number where the malformed section was found.

Another common problem is a missing equals sign. Every non-empty, non-comment line must contain an = separating the key from its value. A line like host localhost will trigger an error because the parser cannot determine where the key ends and the value begins.

Duplicate keys within the same section are handled by keeping the last value encountered, which matches the behavior of Python's configparser module. If you need to preserve multiple values for the same key, consider using a format designed for arrays, or convert your data using a tool like TOML to JSON which natively supports lists.

When to use JSON instead of INI

INI files are simple and readable, making them popular for basic application configuration. However, they lack support for nested structures beyond a single level of sections, arrays, and strict data typing. JSON solves these limitations while remaining widely supported across programming languages.

If your configuration requires deeply nested objects or lists of items, converting ini to json is often the first step before migrating the entire configuration system. Other formats also serve specific niches: for environment variables, an env to JSON converter is more appropriate, and for Java-style configurations, properties to JSON handles the required escaping rules.

JSON is the standard payload format for web APIs, meaning that converting legacy INI files allows older configuration data to be consumed directly by modern frontend and backend services without writing custom parsers.

Reference: INI syntax elements

This table summarizes the syntax elements recognized during the ini to json conversion process. Understanding these elements helps avoid parsing errors when preparing your input.

ElementSyntaxDescription
Section[name]Groups subsequent keys into a nested JSON object.
Key-Valuekey = valueA property assignment. Whitespace around = is ignored.
Comment; text or # textIgnored entirely; not included in the JSON output.
Quoted String"text" or 'text'Preserves exact spacing; outer quotes are removed in JSON.
Global Keykey = valueA key placed before any section header becomes a top-level JSON property.

Worked examples

ExampleInputResult
Basic sectionsINI text: [database] / host = localhost / port = 3306 / [app] / debug = true{ / "database": { / "host": "localhost", / "port": 3306 / }, / "app": { / "debug": true / } / }
Global keys and commentsINI text: ; Global settings / version = 1.0 / # Network / [network] / ip = "192.168.1.1" / enabled = true{ / "version": "1.0", / "network": { / "ip": "192.168.1.1", / "enabled": true / } / }
Quoted stringsINI text: [paths] / home = "/usr/local/bin" / desc = 'A simple path'{ / "paths": { / "home": "/usr/local/bin", / "desc": "A simple path" / } / }

FAQ

What happens to comments in the INI file?

Comments starting with a semicolon or hash symbol are ignored during the ini to json conversion. They do not appear in the resulting JSON output because the JSON specification does not support comments.

Can I convert INI files with no sections?

Yes. Keys defined before any section header are treated as global and become top-level properties in the resulting JSON object.

How are duplicate keys handled?

If the same key appears multiple times within a section or globally, the last value overwrites the previous ones. This matches the standard behavior of most INI parsers.

Does the converter handle quoted values?

Yes. Values wrapped in single or double quotes are treated as strings, and the outer quotes are removed in the JSON output. This prevents numbers or booleans inside quotes from being converted to their respective JSON types.

Is my configuration data sent to a server?

No. The conversion runs entirely in your browser using JavaScript. Your INI text is never uploaded anywhere.

What if my INI file has a syntax error?

The converter stops and displays an error message indicating the exact line number and the nature of the problem, such as a missing closing bracket or a missing equals sign.