trurl is a separate command line tool with the sole purpose of parsing, manipulating and outputting URLs and parts of URLs. A companion tool to curl for your command lines and scripting needs.

trurl uses libcurl’s URL parser. This ensures that curl and trurl always have the same opinion about URLs and that both tools parse them identically and consistently.


Typically you pass in one or more URLs to trurl and specify what components you want output. Possibly while modifying the URL(s) as well.

trurl knows URLs and every URL consists of up to ten separate and independent components. These components can be extracted, removed and updated with trurl.

trurl example command lines

Replace the hostname of a URL:

$ trurl --url --set

Create a URL by setting components:

$ trurl --set --set scheme=ftp

Redirect a URL:

$ trurl --url --redirect here.html

Change port number:

$ trurl --url --set port=8080

Extract the path from a URL:

$ trurl --url --get '{path}'

Extract the port from a URL:

$ trurl --url --get '{port}'

Append a path segment to a URL:

$ trurl --url --append path=you

Append a query segment to a URL:

$ trurl --url "" --append query=search=string

Read URLs from stdin:

$ cat urllist.txt | trurl --url-file -

Output JSON:

$ trurl "" --set user=::moo:: --json
    "url": "",
    "parts": {
      "scheme": "https",
      "user": "::moo::",
      "host": "",
      "path": "/hello",
      "fragment": "frag"

Remove tracking tuples from query:

$ trurl "" \
  --trim query="utm_*"

Show a specific query key value:

$ trurl "" -g '{query:a}'

Sort the key/value pairs in the query component:

$ trurl "" --sort-query

Work with a query that uses a semicolon separator:

$ trurl ";page=5" --trim query="search" \
  --query-separator ";"

Accept spaces in the URL path:

$ trurl " has space/index.html" --accept-space


Everything you want to know about trurl is found at It is probably already available for your Linux distribution of choice.