is-url
A tiny, dependency-free JavaScript utility for loosely validating whether a string is a URL.
Repository Health
Technical Analysis
is-url is a minimal JavaScript utility created by Segment that checks whether a given string looks like a URL. It exposes a single function, isUrl(string), that returns a boolean based on a lightweight regular-expression check covering protocol-relative URLs, localhost addresses, and standard domains.
Because it has zero runtime dependencies and a tiny footprint, it is commonly reached for in form validation, link-detection utilities, and content-sanitization pipelines where a full URL-parsing library would be overkill. The project is feature-complete and in maintenance mode, but remains a dependable building block for both Node.js and browser codebases.
What You Get
- A single exported
isUrl(string)function with no configuration required - Zero runtime dependencies and a sub-1KB implementation
- Support for protocol-relative URLs (
//example.com) and localhost addresses - Works identically in Node.js and browser environments
Common Use Cases
- Validating user-submitted links in forms before persisting them
- Filtering arrays of strings to detect which ones are links
- Guarding link-rendering components (e.g. auto-linking chat or comment text) against non-URL input
- Lightweight pre-checks before passing a value to a heavier URL parser
Under The Hood
Architecture - The entire package is a single CommonJS module (index.js) that exports one function, isUrl(string). Validation happens in two stages: a top-level regular expression (protocolAndDomainRE) strips an optional protocol and captures everything after //, then a second pair of regexes (localhostDomainRE, nonLocalhostDomainRE) checks whether the remainder looks like a localhost address or a standard host.tld domain. There is no internal state, no classes, and no configuration surface — the whole control flow is a handful of match/test calls. Tech Stack - The package has no runtime dependencies at all; mocha is the sole devDependency, used purely for the test suite. It ships as plain ES5 JavaScript with no build step, no TypeScript types, and no bundler configuration, keeping the published artifact identical to the source file. Code Quality - test/index.js exercises the function against a table of valid URLs (http, https, ftp, protocol-relative, localhost with port) and invalid strings (empty string, plain words, malformed protocols), giving reasonable behavioral coverage for such a small surface area, though there are no type definitions or edge-case tests for internationalized domains. Naming is terse but clear (isUrl, protocolAndDomainRE), and the code favors early returns over nested conditionals. API Design - The public API is a single function taking one string argument and returning a boolean, which makes adoption essentially zero-friction — there is nothing to configure, no options object, and the README documents the entire contract in a few lines.
Used by 4 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
CodeSandbox
Code Editors · Developer Tools
Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.
Uptime Kuma
Monitoring
Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.
Zulip
Team Chat
Topic-based team chat that brings the structure of email threads to real-time messaging, so distributed teams never lose context across hundreds of concurrent conversations.