# url-parse-lax

> Lax URL parsing with support for protocol-less URLs and IPs

Latest version **6.0.0** (published 2025-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install url-parse-lax
pnpm add url-parse-lax
yarn add url-parse-lax
bun add url-parse-lax
```

## Health

**Score 38/100 (D)** — status: maintenance-mode.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2025-09-07 |
| First published | 2015-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/url-parse-lax) |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | url, parse, parser, loose, lax, protocol, less, protocol-less, ip, ipv4, ipv6 |

## Links

- npm: https://www.npmjs.com/package/url-parse-lax
- Repository: https://github.com/sindresorhus/url-parse-lax
- Homepage: https://github.com/sindresorhus/url-parse-lax#readme
- Issues: https://github.com/sindresorhus/url-parse-lax/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/url-parse-lax

## Dependencies (1)

- [prepend-http](https://npm.io/package/prepend-http.md) ^4.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 6.0.0 (latest) — 2025-09-07
- 5.0.0 — 2021-08-09
- 4.0.0 — 2019-06-11
- 3.0.0 — 2017-11-03
- 2.0.0 — 2017-10-17
- 1.0.0 — 2015-07-13

## README

# url-parse-lax

> Lax URL parsing with support for protocol-less URLs and IPs

## Install

```sh
npm install url-parse-lax
```

## Usage

```js
import urlParseLax from 'url-parse-lax';

urlParseLax('sindresorhus.com');
/*
{
	protocol: 'https:',
	slashes: true,
	auth: null,
	host: 'sindresorhus.com',
	port: null,
	hostname: 'sindresorhus.com',
	hash: null,
	search: null,
	query: null,
	pathname: '/',
	path: '/',
	href: 'https://sindresorhus.com/',
	searchParams: URLSearchParams {},
	origin: 'https://sindresorhus.com',
	username: null,
	password: null
}
*/

urlParseLax('[2001:db8::]:8000');
/*
{
	protocol: 'https:',
	slashes: true,
	auth: null,
	host: '[2001:db8::]:8000',
	port: '8000',
	hostname: '[2001:db8::]',
	hash: null,
	search: null,
	query: null,
	pathname: '/',
	path: '/',
	href: 'https://[2001:db8::]:8000/',
	searchParams: URLSearchParams {},
	origin: 'https://[2001:db8::]:8000',
	username: null,
	password: null
}
*/
```

And with the built-in `url.parse()`:

```js
import url from 'node:url';

url.parse('sindresorhus.com');
/*
{
	protocol: null,
	slashes: null,
	auth: null,
	host: null,
	port: null,
	hostname: null,
	hash: null,
	search: null,
	query: null,
	pathname: 'sindresorhus.com',
	path: 'sindresorhus.com',
	href: 'sindresorhus.com'
}
*/

url.parse('[2001:db8::]:8000');
/*
{
	protocol: null,
	slashes: null,
	auth: null,
	host: null,
	port: null,
	hostname: null,
	hash: null,
	search: null,
	query: null,
	pathname: '[2001:db8::]:8000',
	path: '[2001:db8::]:8000',
	href: '[2001:db8::]:8000'
}
*/
```

## API

### urlParseLax(url, options?)

#### url

Type: `string`

The URL to parse.

#### options

Type: `object`

##### https

Type: `boolean`\
Default: `true`

Prepend `https://` instead of `http://` to protocol-less URLs.

## Related

- [url-format-lax](https://github.com/sindresorhus/url-format-lax) - Formats a hostname and port into IPv6-compatible socket form of `hostname:port`

---
_Source: https://npm.io/package/url-parse-lax · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
