Skip to content


MIT 103 2 6,258
85 (month) Jun 18 2013 0.1.3(1 year, 10 months ago)
97 1 - MIT
Apr 15 2018 58 (month) v2.1.1(3 months ago)

URI.js is a lightweight JavaScript library for working with URLs and URIs in Node.js and the browser. It provides a simple and consistent interface for parsing, manipulating, and building URLs and URIs.

url is a package for working, modifying and parsing web URLs. This package is for you when PHP's parse_url() is not enough.

Key Features:

  • Parse a URL and access or modify all its components separately.
  • Resolve any relative reference you may find in an HTML document to an absolute URL, based on the document's URL.
  • Get not only the full host of a URL, but also the registrable domain, the domain suffix and the subdomain parts of the host separately (Thanks to the Mozilla Public Suffix List).
  • An advanced API to access and manipulate the URL query component.
  • Compare URLs or components of URLs (e.g. checking if different URLs point to the same host or domain)
  • Thanks to symfony/polyfill-intl-idn it's also no problem to parse internationalized domain names (IDN).
  • Includes an adapter class which implements the PSR-7 UriInterface.

Example Use

const URI = require('uri-js');

// parse url for values
const parsedUrl = URI.parse("");
/* Output:
    scheme: 'https',
    authority: '',
    path: '/search',
    query: 'q=query+string',
    fragment: 'fragment'

// create url from values
const urlComponents = {
    scheme: 'https',
    authority: '',
    path: '/search',
    query: 'q=query+string',
    fragment: 'fragment'
const url = URI.serialize(urlComponents);
// Output: ''
use Crwlr\Url;

$url = new Url('');

// Parse url for parts:
echo $url->scheme();
echo $url->host();
echo $url->path();
echo $url->query();
echo $url->fragment();
// update values
echo $url->path("some/new/query");

// Create url from parts:
$url = new Url();
echo $url->toString();

Alternatives / Similar

Was this page helpful?