Convert JSON object to query string
Build the end of a web address from your values without breaking it: a name, a city, a yes-or-no flag and a score become 4 parameters, and Ada Lovelace travels safely as Ada%20Lovelace. You get the result with and without the question mark. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
Hand-rolling the join of ampersands and equals signs fails as soon as a value contains a space, an ampersand, a non-ASCII letter, or a reserved character.
Why joining parameters by hand breaks
The part of a web address after the question mark is a series of name-equals-value pairs joined by ampersands. Joining them by hand works until a value contains a space, an ampersand, an accented letter or a reserved character; then the address splits in the wrong place or the server reads something you did not send. This tool encodes every name and every value, so Ada Lovelace travels as Ada%20Lovelace and a stray ampersand can never start a new parameter. The encoding follows the same rules the browser uses, so what you build is what the server receives.
Where it helps, and its limits
A web app that keeps its filters and page number as a simple set of values needs one encoder before writing them to the address bar. A service that logs outgoing requests or builds signed links needs the same rules, so access logs and support tickets match what the client really sent. Only flat sets are accepted: nested sections and lists are refused instead of being squeezed into a misleading address. Empty values become empty parameters, the order of your names is kept, and you receive the result with and without the question mark, the number of parameters and the list of pairs.
Where turning values into a web address pays off
Front-end apps that keep filter chips and pagination state as a plain object need a single encoder before writing location.search so multi-value-looking text never splits on a raw ampersand. Backend services that log outbound requests or build signed URLs from configuration maps need the same percent-encoding rules as the browser so support tickets and access logs match what the client actually sent. Failed validation does not consume balance.
Keep maps flat and under the documented limits, pin the encoded query in tests, and you get reproducible parameter strings for dashboards, LMS plugins, and edge workers without standing up a full URL toolkit of your own.
What you can do with it
Build location.search from app state
Turn a flat filter or form object into a percent-encoded query string before writing the browser address bar or history entry.
FAQ
What value types are allowed?
Strings, finite numbers, booleans, and null. Null becomes an empty value after the equals sign.
Are keys and values percent-encoded?
Yes. Both keys and values are encoded with encodeURIComponent so spaces, ampersands, equals signs, and non-ASCII characters cannot invent extra parameters.
What happens to a space or an ampersand in a value?
It is encoded so it cannot split the address in the wrong place. A space becomes %20, as in Ada%20Lovelace, and ampersands, accented letters and other reserved characters are encoded the same way, matching what browsers send.
Can I convert nested data or lists?
No. Only a flat set of names and values is accepted. A nested section or a list is refused with a clear message, so you never end up with an address that looks valid but carries half-structured data.
What happens to an empty value?
An empty value becomes a parameter with its name and nothing after the equals sign, so the name still travels. An empty set of values gives an empty result, which is handy when you need to show that no parameters are sent.
Are the parameters kept in my order?
Yes. They come out in the order the names appear in your data. In the example, name, city, active and score keep that order, and the result also tells you how many parameters there are.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/data/json-to-query-params \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"object":{"name":"Ada Lovelace","city":"London","active":true,"score":42}}'const res = await fetch("https://api.kit.forhosting.com/data/json-to-query-params", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"object": {
"name": "Ada Lovelace",
"city": "London",
"active": true,
"score": 42
}
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/data/json-to-query-params",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"object": {
"name": "Ada Lovelace",
"city": "London",
"active": true,
"score": 42
}
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/data/json-to-query-params", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"object":{"name":"Ada Lovelace","city":"London","active":true,"score":42}}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"object":{"name":"Ada Lovelace","city":"London","active":true,"score":42}}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/data/json-to-query-params", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"object": {
"name": "Ada Lovelace",
"city": "London",
"active": true,
"score": 42
}
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "data.json_to_query_params",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
APIs, front-end routers, and analytics pipelines often hold filters and form fields as a simple JSON map and still need a correctly encoded query string for the address bar or an outbound HTTP client. This capability accepts one flat JSON object, coerces each scalar value to text, percent-encodes every key and value, and returns the ready-to-append query string together with ordered pairs and a normalized string map. Nested objects and arrays are rejected with invalid_input so callers never emit half-structured garbage that looks like a valid URL.
From a flat object to an encoded query string
A URL query string is a sequence of name-equals-value fields joined by ampersands, optionally preceded by a question mark after the path. The result is a query string without inventing extra separators from raw special characters. Empty objects produce an empty query string and a lone question-mark prefix form, which is useful for tests that assert no parameters rather than inventing a dummy key. Length limits on key count and total serialized size keep pathological maps from exhausting memory in the free browser path. When your source of truth is already a JSON object—for example a filter state, a form model, or a config map—you need a deterministic way to turn that map into the wire format browsers and servers expect. This capability walks the object’s own keys in insertion order, converts each scalar value to a stable string (booleans become true or false, finite numbers use ordinary decimal notation, null becomes an empty value), and applies encodeURIComponent to every key and every value so spaces become percent-twenty, ampersands become percent-twenty-six, and Unicode survives transit. Nested objects and arrays are intentionally unsupported: a query parameter is a flat key-value pair, and serializing nested structure into a single opaque string would hide mistakes that callers usually want to fix before the request leaves the client. Because the path is pure string and object work with no network, no random seeds, and no wall-clock timestamps, identical inputs always produce identical JSON. Successful API pricing is the published base of $0.002 per item, and validation failures do not consume prepaid balance.
Input contract, response shape, and error behaviour
The value must be a flat object whose properties are strings, numbers, booleans, or null. Non-finite numbers (NaN and Infinity) are rejected because they have no standard portable form in query strings. Example: name Ada Lovelace, city London, active true, and score forty-two produce a four-parameter string with spaces and any reserved characters percent-encoded. POST a JSON body with a required object field (aliases json, data, params, map, fields). You may also pass object as a JSON text string that parses to such a map. Arrays at the top level, null, scalars, and any nested object or array value fail with invalid_input and a clear English message naming the bad key when relevant. On success the response includes query (the encoded string without a leading question mark), query_with_prefix (the same string with a leading question mark, or a lone question mark when there are no keys), count (the number of parameters), pairs (an ordered array of key and value strings after scalar coercion but before encoding), and object (a last-wins string map of those coerced values). Classic failure: send nested filters under a key such as filter equals an object and receive invalid_input instead of a silently broken URL. Successful API pricing is the published base of $0.002 per item; validation failures are not billed.
Where JSON-to-query conversion earns its keep
Curriculum authors teaching web foundations want a dedicated landing for object-to-query serialization rather than burying the topic under a bidirectional parser, because search intent differs: people holding a JSON map want encoding, not parse mode options.
Integration use cases
Prepare outbound HTTP query parameters
Serialize configuration and request maps into a safe query fragment for clients, webhooks, and signed URL builders.
Golden fixtures for encoding tests
Generate stable query strings from JSON fixtures in CI so spaces, ampersands, and Unicode encode the same way every run.
Technical questions
How do I convert a JSON object to a URL query string?
Send a flat object in the object field (or aliases json, data, params). The response query field is the percent-encoded key=value pairs joined by &; query_with_prefix adds a leading ?.
What if my object is nested?
The capability requires a flat object. Nested structure fails with invalid_input so you can flatten or redesign the map before encoding rather than shipping an ambiguous URL.
What does convert JSON object to query string cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not charged.