npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

uk-company-number

v1.0.0

Published

Validate, format, and identify UK Companies House company numbers

Readme

uk-company-number

Validate, format, and identify UK Companies House company numbers. Zero dependencies.

Built by BORSCH.AI — UK Business Intelligence Platform covering 5.9M companies with AI-powered risk analysis and 50M+ government data signals.

npm version License: MIT

Features

  • Validate UK company numbers (format check)
  • Parse into structured info (jurisdiction, type, prefix)
  • Format/normalize to canonical form
  • Support for all 27 known prefixes (England & Wales, Scotland, NI, LLP, LP, overseas, etc.)
  • Compare two numbers for equality
  • Zero dependencies
  • TypeScript types included
  • ESM and CommonJS support

Installation

npm install uk-company-number

Quick Start

import { validate, parse, format } from "uk-company-number";

// Validate
validate("12345678");   // true (England & Wales)
validate("SC123456");   // true (Scotland)
validate("OC301234");   // true (LLP)
validate("XX000000");   // false (unknown prefix)

// Parse
parse("SC123456");
// {
//   number: "SC123456",
//   prefix: "SC",
//   numericPart: "123456",
//   jurisdiction: "scotland",
//   jurisdictionName: "Scotland",
//   type: "ltd",
//   typeName: "Private Limited Company"
// }

// Format (normalize)
format("123");          // "00000123"
format("sc 123456");    // "SC123456"

API

validate(number: string): boolean

Check if a string is a valid UK company number format.

validate("12345678");    // true
validate("SC123456");    // true
validate("OC301234");    // true
validate("OE012345");    // true (Overseas Entity)
validate("00000000");    // false (all zeros)
validate("XX123456");    // false (unknown prefix)

parse(number: string): CompanyNumberInfo | null

Parse a company number into structured information.

const info = parse("OC301234");
// {
//   number: "OC301234",
//   prefix: "OC",
//   numericPart: "301234",
//   jurisdiction: "england-wales",
//   jurisdictionName: "England & Wales",
//   type: "llp",
//   typeName: "Limited Liability Partnership"
// }

format(number: string): string | null

Normalize a company number to its canonical form.

format("123");           // "00000123"
format("sc123456");      // "SC123456"
format("OC 301234");     // "OC301234"
format("12.345.678");    // "12345678"

getJurisdiction(number: string): string | null

Get the jurisdiction identifier.

getJurisdiction("12345678");  // "england-wales"
getJurisdiction("SC123456");  // "scotland"
getJurisdiction("NI012345");  // "northern-ireland"
getJurisdiction("SE123456");  // "uk"

getType(number: string): string | null

Get the company type identifier.

getType("12345678");  // "ltd"
getType("OC301234");  // "llp"
getType("LP123456");  // "lp"
getType("FC123456");  // "overseas"
getType("SE123456");  // "se"
getType("CE123456");  // "community-interest"

getPrefix(number: string): string | null

Get the letter prefix (empty string for England & Wales).

getPrefix("12345678");  // ""
getPrefix("SC123456");  // "SC"
getPrefix("OC301234");  // "OC"

equals(a: string, b: string): boolean

Check if two numbers refer to the same company.

equals("123", "00000123");       // true
equals("sc123456", "SC123456");  // true
equals("SC123456", "NI123456");  // false

prefixes(): PrefixInfo[]

Get all known prefixes and their descriptions.

prefixes();
// [
//   { prefix: "AC", jurisdiction: "england-wales", type: "assurance", ... },
//   { prefix: "CE", jurisdiction: "england-wales", type: "community-interest", ... },
//   ...
// ]

Supported Prefixes

| Prefix | Jurisdiction | Type | Description | |--------|-------------|------|-------------| | (none) | England & Wales | ltd | Private Limited Company | | SC | Scotland | ltd | Private Limited Company | | NI | Northern Ireland | ltd | Private Limited Company | | R | England & Wales | ltd | Old Public Company (pre-1981) | | OC | England & Wales | llp | Limited Liability Partnership | | SO | Scotland | llp | Limited Liability Partnership | | NC | Northern Ireland | llp | Limited Liability Partnership | | FC | United Kingdom | overseas | Overseas Company | | SF | Scotland | overseas | Overseas Company | | NF | Northern Ireland | overseas | Overseas Company | | OE | United Kingdom | overseas | Overseas Entity | | LP | England & Wales | lp | Limited Partnership | | SL | Scotland | lp | Limited Partnership | | NL | Northern Ireland | lp | Limited Partnership | | IP | England & Wales | industrial-provident | Industrial & Provident Society | | SP | Scotland | industrial-provident | Industrial & Provident Society | | NP | Northern Ireland | industrial-provident | Industrial & Provident Society | | RC | England & Wales | royal-charter | Royal Charter Company | | SR | Scotland | royal-charter | Royal Charter Company | | NR | Northern Ireland | royal-charter | Royal Charter Company | | SE | United Kingdom | se | Societas Europaea | | GE | United Kingdom | eeig | European Economic Interest Grouping | | CE | England & Wales | community-interest | Community Interest Company | | CS | Scotland | community-interest | Community Interest Company | | AC | England & Wales | assurance | Assurance Company | | SA | Scotland | assurance | Assurance Company | | NA | Northern Ireland | assurance | Assurance Company |

Data Source

Based on the official Companies House company number format specifications.

Need More Company Data?

This package validates company number formats. To look up full company details — financials, directors, risk scores, government signals, and AI-powered analysis across 5.9 million UK companies — visit borsch.ai.

License

MIT