Skip to content
OddsockLocal
Local
Source text

Formatting

5 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste an absolute URL.
  2. Read protocol, hostname, port and path.
  3. Read parameters as decoded pairs. A plus is a space.
  4. Read the fragment, including the leading #. It is empty when the URL has none.

What is URL parser?

URL parser breaks one absolute URL into the pieces a browser already computed and people usually reimplement wrong. https://shop.example:8443/search?q=wool+socks#results comes back with protocol https:, hostname shop.example, port 8443, path /search, one parameter pair q and wool socks, and fragment #results. The plus in the query is decoded to a space inside the parameter value. The fragment keeps its hash mark.

Read more

The port is empty when the URL uses the default and does not write one. The path is the pathname only, so a missing path is /. Parameters are pairs in order, the same decoding as the query parser, nested under this object rather than returned alone.

A string that is not an absolute URL throws. Odd socks in the dryer. is not a URL, and neither is a schemeless host. There is no “try to fix it” pass. Internationalized domains are whatever the URL parser in the browser produces.

Use cases

  • A redirect string hides a non-default port and you want 8443 visible before you compare environments.
  • The fragment and the query are being confused, and you want #results separate from q.
  • A plus in q=wool+socks should be read as a space, not as part of the product name.
  • You have a URL and you need the hostname alone, without re-splitting on slashes and forgetting the port.

A non-default port, a query and a fragment

https://shop.example:8443/search?q=wool+socks#results

protocol https:, hostname shop.example, port 8443, path /search, parameters [["q", "wool socks"]], fragment #results.

Why use Oddsock

The port field stays separate from the host. Concatenating them yourself is how :8443 ends up in the wrong config.

Related tools

Using this tool

The page reports the URL’s hash as the platform defines it, mark included. An empty fragment is an empty string, not a missing field.