URL

JSON

What does URL to JSON do?

You paste a URL on the left, and on the right you get a JSON object with the URL's pieces named — protocol, host, pathname, searchParams, hash, all of it. The point isn't to look at it once and move on. The point is to copy that JSON into a place where it lives — a config file, a Jest fixture, a Postman environment, a YAML manifest, a request-mock for your tests. URL strings are easy to type but hard to assert against; structured objects are the opposite.

Under the hood it's the same algorithm every browser uses through the URL API, which implements the WHATWG URL Standard. Query parameters get decoded along the way — %20 becomes a space, %5B becomes [, repeated keys collapse into a JSON array — same behaviour you get from URLSearchParams. The output is then formatted via the same JSON.stringify rules every other JSON tool on this site uses.

If you just want to look at a URL's parts on screen — debug a redirect, eyeball a tracker chain — the URL Parser page is the better surface. Both pages run the same conversion; this one is framed for the case where the JSON itself is the artefact you keep. Everything is local to your browser, no upload, no logs. The conversion follows RFC 3986 for syntax and RFC 8259 for the JSON output.

How to Convert a URL to JSON

Three steps. Each one matches a button on this page.

1

Paste a URL or Load the Sample

Drop a URL into the left panel. Click Sample to load a realistic e-commerce URL with percent-encoding, repeated query keys, and a hash fragment. Sample:

https://api.shop.example.com/v1/orders?customer=Ava%20Chen&status=active&total%5Bgte%5D=49.99&page=2#summary

Anything the URL constructor accepts works — <code>http://</code>, <code>https://</code>, <code>file://</code>, <code>mailto:</code>, IPv6 hosts, and userinfo.

2

Read the JSON Output

The right panel updates as you type. You'll see protocol, host, port, pathname, pathSegments (the path split into an array), searchParams (decoded key-value pairs, with arrays for repeated keys), and hash. The href field carries the canonical, normalised form of the URL — useful when you need to assert that two URLs are equivalent even if one had a default port or trailing slash.

3

Copy, Download, or Minify for Your Fixture

Click Copy to send the JSON to your clipboard, Download to save it as url.json, or Minify to compact it onto one line for a log entry or a query parameter. Clear on the input panel resets both editors.

When You'd Actually Use This

Building HTTP request fixtures

When your tests assert against a URL, asserting against a string is brittle — case, default ports, trailing slashes, parameter order all bite. Convert the URL to JSON, drop the object into your fixture, and assert field-by-field. Pairs cleanly with libraries like Mock Service Worker or Nock that match on URL shape.

Seeding API clients in config files

A YAML or JSON config that stores a base URL as a single string forces every consumer to re-parse it. Storing it pre-decomposed (host, port, basePath, defaultParams) makes the config self-documenting and removes a class of "did we forget the trailing slash" bugs. Useful for SDK generators and OpenAPI tooling.

OAuth and webhook callback documentation

When you're writing docs that show "your callback URL will look like this," shipping a JSON breakdown alongside the raw URL is much friendlier to the reader. Standards like RFC 6749 require specific query parameters; a structured form makes "you should see state here" obvious at a glance.

Postman / Bruno / HTTPie environment exports

Most API clients store URLs as decomposed objects internally. If you're importing legacy URLs into a new collection — say, migrating from a docs site that lists endpoints as plain strings — converting them to JSON first lets you script the import instead of clicking through 200 endpoints by hand.

Common Questions

How is this different from the URL Parser page?

Same engine, different framing. URL Parser is for inspection — you paste a long URL, look at the parts, decide what's wrong, close the tab. URL to JSON is for taking the result and using it somewhere — a fixture file, a config, a Postman environment. The JSON output is identical; the page copy and the use cases are tuned for the "I want this in a file" workflow.

Why is the output JSON instead of YAML or a JS object literal?

JSON is the lowest common denominator — every language, every config system, every test framework reads it. If you need YAML, run the JSON through our JSON to YAML tool. If you need a JS object literal, JSON is already valid JS — just paste it into your .ts file. The conversion follows RFC 8259 so the output works anywhere JSON is accepted.

How are repeated query keys represented?

Repeated keys collapse into an array. ?tag=red&tag=blue becomes "tag": ["red", "blue"]. This matches how Express, FastAPI, ASP.NET, Spring, and most frameworks parse query strings — and it's what URLSearchParams.getAll() returns.

What about bracket-notation arrays like ?items[]=1&items[]=2?

The brackets are kept as part of the key — you'll see "items[]": ["1", "2"] in the output. That's a faithful representation of the bytes on the wire. If your framework (PHP, Rails, qs.js) needs the brackets stripped or expanded into a nested object, do that in a post-processing step on the JSON.

Does the JSON include the password if my URL has user:pass@host?

Yes — the username and password fields will appear in the output if your URL has them. The conversion runs entirely in your browser, so the credentials never leave your machine. That said, putting credentials in URLs is generally a bad idea (see RFC 3986 §3.2.1), and you almost certainly want to strip them before committing the JSON to a repo.

Can I convert a list of URLs in one go?

Not in this page — each session converts one URL. If you have a hundred URLs to process, the easiest path is to paste this page's output structure into a small script and loop. Or use our JSON Formatter after you've scripted the batch yourself. Batch conversion as a UI feature is on the roadmap but not shipped yet.

Other URL & JSON Tools

Conversion is one operation. Here's what else pairs naturally with it: