command-line URL parser. single binary, no dependencies. osx & linux & windows.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

url - command-line URL parser

url parses its arguments as URLs and prints a structured representation (JSON or go template) to stdout.

print output JSON output

Get it

Using go get:

go get -u

Or download the binary from the releases page.

# Linux
curl -L | tar xz

# OS X
curl -L | tar xz

# Windows
curl -LO

Also available as a docker image:

docker pull

Use it

url reads URLs from CLI arguments and writes to stdout.

Usage of url:
  -t string
    	alias for -template
  -template string
    	go template output
  -p	alias for -plain
    	plain URL output (useful with -set-* flags)
  -r	alias for -resolve
    	resolve ../ in URLs
  -set-fragment value
    	set the fragment component
  -set-host value
    	set the host component
  -set-hostname value
    	set the hostname component
  -set-opaque value
    	set the opaque component
  -set-path value
    	set the path component
  -set-port value
    	set the port component
  -set-query value
    	set the (raw) query component
  -set-scheme value
    	set the scheme component
  -set-username value
        set the username component
  -set-password value
        set the password component
    	print version and exit

JSON output

The default output format is JSON, one object per line:

$ url

Template output

You can specify an output template using the -template parameter and go template syntax:

$ url -t .Hostname

The fields available to the template are specified in the flatURL struct.

Setting URL components

You can modify the URLs before they are printed using the -set-* parameters. This probably most useful together with the -p (plain URL) output:

$ url -p -set-port 443

This can also be used to build URLs:

$ url -p -set-host -set-scheme https -set-path /sgreben/url/cmd/url ""


Feel free to leave a comment or create an issue.