28 Unix tools. One binary. Zero dependencies.·the missing coreutils for the agent era·try vrk in your browser at vrk.sh/play·curl vrk.sh/install.sh | sh - ready in 5 seconds·

vrk urlinfo

Try it in your browser

vrk, compiled to WebAssembly

# Splits a URL into its parts as JSON.

Enter runs, Shift+Enter adds a line
    output
    Press RUN. Nothing leaves your browser.

    files you can cat:

    Edit the command and press RUN. Open the full playground for more recipes, or install vrk to run it on your own files.

    vrk urlinfo parses URLs into structured JSON components with dot-path field extraction.

    The problem

    cut -d'/' -f3 extracts a hostname until a URL has a port number or basic auth. https://api.example.com:8080/path returns “api.example.com:8080” including the port. A URL with user:pass@host breaks the regex entirely. The 10% of URLs that don’t fit a simple pattern break the pipeline.

    The solution

    vrk urlinfo parses URLs into structured JSON components: scheme, host, port, path, query parameters, fragment, and user. Use --field with a dot-path to extract one component. It handles edge cases that regex approaches miss. It makes no network calls.

    Before and after

    Before

    echo 'https://api.example.com:8080/path?q=test' | cut -d'/' -f3
    # Returns "api.example.com:8080" - includes port
    

    After

    vrk urlinfo --field host 'https://api.example.com:8080/path?q=test'
    

    Example

    vrk urlinfo 'https://api.example.com:8080/v1/search?q=llm+tools&limit=10'
    

    Exit codes

    CodeMeaning
    0Success
    1Invalid URL that cannot be parsed, I/O error
    2Interactive TTY with no stdin or positional arg

    Flags

    FlagShortTypeDescription
    --field-FstringExtract a single field as plain text (supports dot-path for query params)
    --json-jboolAppend metadata trailer
    --quiet-qboolSuppress stderr output

    How it works

    vrk urlinfo splits a URL into its parts (scheme, host, port, path, query, fragment, user) and prints them as JSON.

    Full JSON output

    $ vrk urlinfo 'https://api.example.com:8080/v1/search?q=llm+tools&limit=10#results'
    {"scheme":"https","host":"api.example.com","port":8080,"path":"/v1/search","query":{"limit":"10","q":"llm tools"},"fragment":"results","user":""}
    

    urlinfo puts every URL part in one JSON object. It parses the query parameters into a nested object.

    Extract a single field (–field)

    $ vrk urlinfo --field host 'https://api.example.com:8080/v1/search'
    api.example.com
    
    $ vrk urlinfo --field path 'https://api.example.com:8080/v1/search'
    /v1/search
    
    $ vrk urlinfo --field query.q 'https://api.example.com?q=llm+tools'
    llm tools
    

    A dot path reaches a query parameter, for example query.q or query.page.

    Batch processing

    $ printf 'https://a.com/path\nhttps://b.com/other\n' | vrk urlinfo --field host
    a.com
    b.com
    

    urlinfo reads one URL per line.

    JSON metadata (–json)

    $ printf 'https://a.com\nhttps://b.com\n' | vrk urlinfo --json
    {"scheme":"https","host":"a.com",...}
    {"scheme":"https","host":"b.com",...}
    {"_vrk":"urlinfo","count":2}
    

    Available fields

    FieldExample value
    schemehttps
    hostapi.example.com
    port8080 (0 if not specified)
    path/v1/search
    query{"q":"llm tools","limit":"10"}
    query.<key>value of a specific parameter
    fragmentresults
    userusername (from user@host URLs)

    Pipeline integration

    Group URLs by domain

    # Extract unique domains from a list of URLs
    cat urls.txt | while IFS= read -r url; do
      vrk urlinfo --field host "$url"
    done | sort -u
    

    Extract and decode query parameters

    # Get a query parameter and decode it
    vrk urlinfo --field query.q 'https://example.com?q=hello%20world' | vrk pct --decode
    
    # Grab a page, extract links, group by domain
    vrk grab https://example.com | vrk links --bare | \
      while IFS= read -r url; do
        vrk urlinfo --field host "$url"
      done | sort | uniq -c | sort -rn
    

    When it fails

    If the URL is invalid, urlinfo exits 1:

    $ vrk urlinfo 'not a url'
    error: urlinfo: invalid URL: not a url
    $ echo $?
    1
    

    If you give no input on an interactive terminal, urlinfo exits 2:

    $ vrk urlinfo
    usage error: urlinfo: no input: pipe a URL to stdin
    $ echo $?
    2