uk-company-number
v1.0.0
Published
Validate, format, and identify UK Companies House company numbers
Maintainers
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.
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-numberQuick 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"); // falseprefixes(): 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
