Form Data to JSON Converter

Parses application/x-www-form-urlencoded text into JSON: each key=value pair is percent-decoded, bracket-path field names like user[roles][0] are rebuilt into nested objects and arrays, and a plain key with no brackets becomes a top-level scalar. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

A raw application/x-www-form-urlencoded request body (from a browser form submission, a proxy log, or an API test) is hard to read and even harder to compare against expected data as flat percent-encoded text.

This tool parses it into structured, nested JSON, rebuilding bracket-path field names back into the objects and arrays they represent.

What Is Form Data to JSON Converter?

A parser for application/x-www-form-urlencoded text that decodes every key=value pair, splits bracket-path keys like user[roles][0] into a segment list, and walks that list to build up a single nested JSON structure.

It mirrors the bracket-path convention used by PHP, Rails, and Express's qs library for representing nested data in form submissions.

How Form Data to JSON Converter Works

The input is split on &, each resulting pair is split on its first = (erroring clearly if there isn't one), and both the key and value are decoded with decodeURIComponent.

The decoded key is split into a base name plus a list of [segment] groups via a regular expression, then the parser walks that path one segment at a time: at each step, if the next segment looks like a non-negative integer, it creates an array container there, otherwise an object, before finally assigning the decoded value at the last segment.

When To Use Form Data to JSON Converter

Use it to inspect the actual structure of a form submission or API request body captured from browser dev tools or a proxy log.

It's also useful for round-tripping data produced by JSON to Form Data back into JSON to verify the conversion.

Features

Advantages

  • Correctly rebuilds arbitrarily deep bracket-path nesting into proper JSON arrays and objects, not just a flat key-value map.
  • Decides array vs. object per container based on the actual path segments, matching how common server frameworks interpret the same field names.
  • Reports a specific, actionable error when a pair is missing its = separator.

Limitations

  • All values are parsed as strings; there's no automatic coercion of "true"/"false"/numeric-looking values into their JSON boolean/number equivalents.
  • A field name whose bracket path conflicts with another field's type at the same position (e.g. both a[0] and a[foo] present) will produce unpredictable results, since one path expects an array and the other an object at the same node.

Examples

Bracket-path fields rebuilt into nested JSON

Input

a=1&b%5Bc%5D=2&b%5Bd%5D%5B0%5D=x

Output

{
  "a": "1",
  "b": {
    "c": "2",
    "d": [
      "x"
    ]
  }
}

b[c] and b[d][0] both build nested containers under the shared key b, with d becoming an array because its next segment, "0", is a numeric index.

A pair with no = sign

Input

justtext

Output

Pair "justtext" is missing "=".

Without an = separator, there's no way to tell where the key ends and the value begins, so parsing fails with a specific message.

Best Practices & Notes

Best Practices

  • Cast string values to numbers or booleans yourself after parsing if your application needs typed data; this converter deliberately keeps every value as the original decoded string.
  • Use JSON to Form Data first if you want guaranteed-parseable input for testing this converter.
  • Watch for mixed array/object usage under the same key path in captured real-world data; it's a sign the original form had inconsistent field naming.

Developer Notes

The path-walking logic decides array vs. object per container by checking the next segment before creating anything, an empty JS object {} would otherwise be indistinguishable from an array once populated with numeric string keys, so the explicit lookahead is what makes JSON.stringify emit proper [...] arrays instead of {"0": ..., "1": ...} objects.

Form Data to JSON Converter Use Cases

  • Inspecting a captured form submission or API request body as structured JSON
  • Debugging why a server-side form parser produced an unexpected nested structure
  • Round-tripping output from JSON to Form Data to verify the encoding is correct

Common Mistakes

  • Expecting numeric-looking values to come back as JSON numbers; every value is parsed as a plain string.
  • Using inconsistent bracket paths for the same key (mixing array-style and object-style segments), which produces ambiguous results.
  • Forgetting that a key with no brackets at all becomes a simple top-level scalar field, not a single-item array.

Tips

  • If a field's type comes out wrong, check whether its bracket path is consistent everywhere it's used in the source data.
  • Use JSON to Form Data to generate valid test input if you're unsure of the exact bracket-path syntax this parser expects.

References

Frequently Asked Questions