REGEXVAULTv2.0
Localization/Phone Numbers
Verified Safe

German Phone Number Regex for JavaScript

/^(?:\+49[\s.-]?|0)(?:[1-9][0-9]{1,4})[\s.-]?[0-9]{5,10}$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching german phone number, ported and verified for JavaScript. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// German Phone Number
// ReDoS-safe | RegexVault — Localization > Phone Numbers

const germanPhoneNumberRegex = /^(?:\+49[\s.-]?|0)(?:[1-9][0-9]{1,4})[\s.-]?[0-9]{5,10}$/;

function validateGermanPhoneNumber(input: string): boolean {
  return germanPhoneNumberRegex.test(input);
}

// Example
console.log(validateGermanPhoneNumber("+49 30 12345678")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
+49 30 12345678+49 0 12345678
030 1234567800 12345678
+4915123456789+44 30 12345678
015123456789030 1234
+49 89 1234567

When to use this pattern

This pattern is drawn from the Localization > Phone Numbers category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

German phone numbers have variable lengths depending on the area code — rural areas have longer area codes and shorter subscriber numbers. Total digits in Germany are 10-11 (excluding country code).

Technical Notes

German area codes range from 1 (national services) to 9 (various regions). Mobile numbers start with 015, 016, or 017. Berlin is 030, Munich is 089, Hamburg is 040. Numbers vary in total length (10-11 digits).

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern