phone number standards

Sent logo
Sent TeamMar 8, 2026 / phone number standards / Article

Spain Phone Number Format: Complete Validation & Developer Guide (+34)

Master Spanish phone number formats with our comprehensive developer guide. Learn +34 country code structure, mobile/landline validation, E.164 formatting, and regulatory compliance for building telecom apps.

Spain Phone Numbers: Format, Area Code & Validation Guide

Spanish phone numbers follow a standardized 9-digit format with the +34 country code. This comprehensive guide covers phone number structure, validation patterns, regulatory requirements, and implementation best practices for developers building telecommunications applications for the Spanish market.

Understanding the Spanish Numbering System

Spain's telecommunications infrastructure adheres to a structured 9-digit numbering system. The regulatory framework was modernized in June 2022 by Law 11/2022 (General Telecommunications Act), which superseded Law 9/2014 (https://www.global-regulation.com/translation/spain/1452763/law-9-2014,-of-9-may,-general-telecom.html). This law ensures consistency and interoperability across all services.

Regulatory Authority: The Comisión Nacional de los Mercados y la Competencia (CNMC) regulates the Spanish telephone numbering plan, manages number allocation, enforces telecommunications regulations, and maintains the National Telephone Numbering Plan. The State Secretariat for Telecommunications and Digital Infrastructures also shares regulatory responsibilities.

Core Components of a Spanish Phone Number

Every Spanish phone number consists of three key elements:

plaintext
+34 | Service Identifier | Subscriber Number
    |        (1-2 digits)     | (7-8 digits)
  • Country Code (+34): Spain's unique international identifier. Use this when dialing from outside Spain.
  • National Significant Number (NSN): Always 9 digits long and represents the core phone number within Spain.
  • Internal Structure: The NSN divides into a Service/Area Identifier (1-2 digits) and the Subscriber Number (the remaining 7-8 digits). In some cases, a Network Code is embedded within the Service Identifier.

How to Dial Spain Phone Numbers: International & Domestic Examples

Domestic calls within Spain:

javascript
// All calls require the full 9-digit number
const domesticCall = "913456789"; // Madrid landline

International calls to Spain:

javascript
// From US/Canada: 011 + 34 + 9-digit number
const fromUS = "011 34 913456789";

// From Europe: 00 + 34 + 9-digit number
const fromEU = "00 34 913456789";

// From mobile (universal): + format
const fromMobile = "+34913456789";

E.164 Format (for API/database storage):

javascript
// E.164 format: +[country code][NSN] with no spaces
const e164Format = "+34913456789"; // Always store this way

Key Regulatory Principles

The Spanish numbering system operates under a comprehensive regulatory framework. Consider these principles when designing your applications:

  • Standardization: The unified 9-digit system simplifies number handling across all services.
  • Portability: Users can retain their numbers when switching providers. Account for this in your database design.
  • Resource Management: Number ranges are allocated efficiently to ensure long-term availability.
  • Consumer Protection: Regulations ensure clear pricing and service identification, impacting how you present calling costs.
  • Quality Assurance: Mandatory service standards ensure a reliable telecommunications experience.

Best Practice: Always validate and store Spanish numbers using the full 9-digit NSN format to ensure compatibility across all service types.

E.164 Storage Best Practices

For database storage and API integration, follow the E.164 international standard:

  • Format: +34 followed by the 9-digit NSN with no spaces, parentheses, or hyphens
  • Example: +34913456789 (not +34 91 345 6789 or 913-456-789)
  • Database field type: VARCHAR(15) or TEXT to preserve formatting
  • Maximum length: 15 digits (E.164 limit)
  • Benefits: Ensures global uniqueness, enables proper routing for calls/SMS, and prevents duplication
sql
-- Recommended database schema
CREATE TABLE contacts (
    id SERIAL PRIMARY KEY,
    phone_e164 VARCHAR(15) NOT NULL,  -- E.164 format
    phone_display VARCHAR(30),         -- User-friendly display format
    country_code VARCHAR(3) DEFAULT 'ES'
);

Spanish Phone Number Types: Mobile, Landline & Special Services

Geographic Numbers (Landlines)

Geographic numbers are tied to specific geographic areas within Spain. Their format reflects historical telecommunications development and population density. Certain prefixes correspond to major metropolitan areas.

Important: Due to number portability regulations, geographic prefixes indicate the original allocation region but do not guarantee the current carrier or physical location of the line.

RegionFormatExamplePopulation Served (approx.)
Madrid Metropolitan91X XXX XXX913 456 789~6.7M
Barcelona/Catalonia93X XXX XXX934 567 890~7.5M
Valencia Region96X XXX XXX963 456 789~5M
Andalusia (Seville/Málaga)95X XXX XXX954 567 890~8.4M
Basque Country94X XXX XXX944 567 890~2.2M
Galicia (A Coruña)981 XXX XXX981 567 890~1.1M
Balearic Islands971 XXX XXX971 567 890~1.2M
Canary Islands (Tenerife)922 XXX XXX922 567 890~0.9M
Canary Islands (Las Palmas)928 XXX XXX928 567 890~1.1M

For a complete list of all provincial prefixes, see the Wikipedia reference.

Validating Geographic Numbers

Use regular expressions to validate geographic numbers in your application. Here's an example in JavaScript:

javascript
// Regex for validating Spanish geographic numbers
const geoNumberPattern = /^9[1-9][0-9]{7}$/; // Matches 9 followed by 1-9, then 7 digits
const isValidGeoNumber = (number) => geoNumberPattern.test(number);

// Example usage
console.log(isValidGeoNumber("913456789")); // true
console.log(isValidGeoNumber("903456789")); // false (invalid prefix)
console.log(isValidGeoNumber("91345678"));  // false (incorrect length)

This code snippet demonstrates a basic validation check. For production environments, use libphonenumber or google-libphonenumber for comprehensive validation with carrier detection and number portability handling.

Production-grade validation with libphonenumber:

javascript
// Using google-libphonenumber (JavaScript/Node.js)
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
const PNF = require('google-libphonenumber').PhoneNumberFormat;

function validateSpanishNumber(numberString) {
  try {
    const number = phoneUtil.parse(numberString, 'ES');
    return {
      valid: phoneUtil.isValidNumber(number),
      type: phoneUtil.getNumberType(number),
      e164: phoneUtil.format(number, PNF.E164),
      international: phoneUtil.format(number, PNF.INTERNATIONAL)
    };
  } catch (error) {
    return { valid: false, error: error.message };
  }
}

// Example usage
console.log(validateSpanishNumber("913456789"));
// { valid: true, type: 0, e164: '+34913456789', international: '+34 913 45 67 89' }
python
# Using phonenumbers library (Python)
import phonenumbers
from phonenumbers import NumberParseException

def validate_spanish_number(number_string):
    try:
        parsed = phonenumbers.parse(number_string, "ES")
        return {
            "valid": phonenumbers.is_valid_number(parsed),
            "type": phonenumbers.number_type(parsed),
            "e164": phonenumbers.format_number(parsed, phonenumbers.PhoneNumberFormat.E164),
            "international": phonenumbers.format_number(parsed, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
        }
    except NumberParseException as e:
        return {"valid": False, "error": str(e)}

# Example usage
print(validate_spanish_number("913456789"))

Mobile Numbers

Spain's mobile numbering system has evolved to accommodate growing demand. Two main ranges exist:

Traditional Ranges (6XX XXX XXX)

Originally allocated in the 1990s, these ranges are widely recognized. All major mobile operators use these prefixes.

Extended Ranges (7YX XXX XXX)

Introduced in 2009–2010 to meet increasing demand, these ranges are primarily used for IoT devices, M2M communication, and newer service types. The 'Y' in the prefix can be any digit from 1 to 9 (not 0, which is reserved for personal numbers).

mermaid
graph LR
    A[Mobile Number] --> B(6XX XXX XXX)
    A --> C(7YX XXX XXX)
    B --> D[Traditional Mobile]
    C --> E[IoT/M2M/New Services]

Important Note: Spanish mobile numbers are not available as virtual numbers. You need a physical SIM card for these.

Implications for Developers:

  • Physical SIM requirement means you must use local carrier services for Spanish mobile numbers
  • For SMS verification or voice services, use third-party providers with Spanish number inventory
  • Virtual number services (like VoIP providers) cannot provide genuine Spanish mobile numbers (6XX/7YX ranges)
  • Compliance: Ensure your application clearly identifies whether a number is virtual or physical when regulations require it

Premium and Special Service Numbers

These numbers offer specialized services and incur higher charges for the caller. Handle these carefully and transparently.

Service TypePrefixRate StructureMax Rate/MinRequired Warnings
Adult Services803Setup fee + per minute after 20s€0.79–€6.05Age verification, cost disclosure
Entertainment806Setup fee + per minute after 20s€0.79–€6.05Cost disclosure
Professional Services807Setup fee + per minute after 20s€0.79–€6.05Service description, cost disclosure
Mass Calling/TV Voting905Fixed per-call fee€0.91–€2.00Cost per call
Directory Enquiries118XYVariableVariableCost per call

Pricing Details (as of 2018, rates subject to change):

  • Setup fee: €0.20 (all premium numbers)
  • Per-minute rates apply only after the first 20 seconds
  • Rates vary by third digit: 803X/806X/807X where X determines pricing tier
  • Sources: Lobster Spain Price Guide, Wikipedia

Legal Requirements:

  • Premium numbers must comply with Spanish Consumer Protection regulations
  • GDPR applies to all call data collection and storage
  • Callers must receive clear cost warnings before connection
  • Age verification required for adult services (803)
  • Call recordings and transcripts must be maintained for audit purposes
  • Registration with CNMC required for premium number services

Developer Considerations for Premium Numbers

When integrating premium-rate numbers into your application:

  • Implement clear cost warnings: Inform users about charges before they connect.
  • Include mandatory service descriptions: Clearly explain the service being offered.
  • Implement age verification where required: Restrict access to adult services.
  • Maintain detailed call records: Store call metadata (duration, timestamp, costs) for regulatory compliance.
  • Support real-time billing information: Provide users with up-to-date cost information during the call.
  • Error handling: Implement robust error handling for failed connections, timeout scenarios, and payment failures.

Important Note: Spanish customer service regulations (Law 11/2022, Royal Decree 899/2009) mandate that customer support must be provided via freephone numbers (800/900), and callers should be connected to a human representative within 3 minutes in 95% of cases. Spain's Customer Service Law (enacted 2023–2024) reinforces these requirements. Violations can result in fines up to €20 million for very serious infringements. Sources: Enreach Spain, DLA Piper.

Internet Access Numbers (908/909 XXX XXX)

These numbers were historically used for dial-up internet access. While still technically valid, they are largely obsolete. Avoid implementing support for these unless specifically required for legacy systems. Consider blocking or flagging these numbers in modern applications.

Freephone Numbers (800 XXX XXX and 900 XXX XXX)

These numbers are free for the caller, with the called party bearing the cost. They are commonly used for customer service and support lines. Spanish consumer protection law and the Customer Service Law require freephone numbers for customer support in regulated sectors (utilities, transport, postal, telecoms, financial services) and companies with over 250 employees or €50M annual turnover.

Non-Geographic Numbers (901/902 XXX XXX)

These numbers are not tied to a specific geographic location and are often used by call centers. Pricing structure:

  • 901 numbers: Shared-cost calls. Setup fee €0.19, per-minute rate €0.37.
  • 902 numbers: National rate calls charged entirely to caller. Setup fee €0.19, per-minute rate €0.55.
  • 910+ numbers: Standard non-geographic numbers with regional or national rate pricing.

Important: 901 and 902 numbers are excluded from inclusive call bundles and can be expensive when calling from mobiles or internationally. EU regulations prohibit using premium-rate or shared-cost numbers for customer service lines – provide freephone alternatives.

Additional non-geographic ranges:

  • 5XX XXX XXX: Personal numbering services (redirect to any number)
  • 70X XXX XXX: Personal numbers (flexible redirection)

Emergency and Short Numbers

Developers building dialer applications or communication platforms must ensure these numbers are always accessible:

  • 112: Pan-European emergency number (police, fire, medical)
  • 061: Medical emergencies (regional availability varies)
  • 091: National Police
  • 092: Municipal/Local Police
  • 080/085: Fire brigade (varies by province)
  • 016: Violence against women hotline (calls don't appear on phone bills)
  • 010: Municipal government information
  • 012: Regional government information

Never block, rate-limit, or subject these numbers to payment requirements.

SMS and MMS Capabilities

Spanish phone numbers support standard SMS and MMS services:

  • SMS: All mobile numbers (6XX, 7YX) support SMS. Character limit: 160 characters (GSM-7), 70 characters (Unicode).
  • MMS: Supported on all mobile numbers with data-capable devices.
  • Landlines: Geographic numbers (9XX, 8XX) do not support SMS/MMS.
  • API Integration: Use providers like Twilio, Vonage, or local carriers (Movistar, Vodafone, Orange) for SMS gateway access.

Best practices:

  • Validate mobile numbers before SMS sending
  • Implement delivery receipts and error handling
  • Comply with Spanish anti-spam regulations and GDPR
  • Provide opt-out mechanisms for marketing messages

Phone Number Validation Libraries and Tools

For production applications, use established libraries rather than custom regex:

LanguageLibraryRepository/Package
JavaScript/Node.jsgoogle-libphonenumbernpm
JavaScriptlibphonenumber-jsnpm
PythonphonenumbersPyPI
PHPlibphonenumber-for-phpPackagist
JavalibphonenumberGitHub
RubyphonelibRubyGems
C#libphonenumber-csharpNuGet

Reference: Google libphonenumber GitHub

Quick Reference: Validation Patterns

javascript
// Quick validation patterns for Spanish numbers
const patterns = {
  mobile: /^[67][0-9]{8}$/,           // Mobile: 6XX XXX XXX or 7YX XXX XXX
  geographic: /^[89][0-9]{8}$/,       // Landline: 8XX XXX XXX or 9XX XXX XXX
  freephone: /^[89]00[0-9]{6}$/,      // 800 or 900
  premium: /^80[367][0-9]{6}$/,       // 803, 806, 807
  sharedCost: /^90[12][0-9]{6}$/,     // 901, 902
  emergency: /^(112|061|091|092|016)$/, // Emergency numbers
  e164: /^\+34[6-9][0-9]{8}$/         // E.164 format
};

// Validation function
function identifySpanishNumber(number) {
  // Remove spaces and formatting
  const clean = number.replace(/[\s\-\(\)]/g, '');

  // Check E.164 format
  if (patterns.e164.test(clean)) {
    return { format: 'e164', nsn: clean.slice(3) };
  }

  // Check NSN format (9 digits)
  if (clean.length === 9) {
    if (patterns.mobile.test(clean)) return { type: 'mobile', nsn: clean };
    if (patterns.geographic.test(clean)) return { type: 'geographic', nsn: clean };
    if (patterns.freephone.test(clean)) return { type: 'freephone', nsn: clean };
    if (patterns.premium.test(clean)) return { type: 'premium', nsn: clean, warning: 'PREMIUM_RATE' };
    if (patterns.sharedCost.test(clean)) return { type: 'sharedCost', nsn: clean, warning: 'CHARGED' };
  }

  // Check emergency
  if (patterns.emergency.test(clean)) return { type: 'emergency', nsn: clean };

  return { type: 'invalid', error: 'Invalid Spanish number format' };
}

Frequently Asked Questions

Q: What is the country code for Spain? A: Spain's country code is +34. When calling Spain from abroad, dial your country's exit code (011 from US, 00 from Europe), then +34, followed by the 9-digit Spanish phone number.

Q: How many digits are in a Spanish phone number? A: Spanish phone numbers are always 9 digits long. This applies to all number types: mobile (starting with 6 or 7), landline (starting with 8 or 9), and special services.

Q: Can I use a Spanish mobile number without a physical SIM? A: No. Spanish mobile numbers (6XX, 7YX) require a physical SIM card. Virtual number services cannot provide genuine Spanish mobile numbers.

Q: How do I format a Spanish phone number for international calling? A: Use E.164 format: +34 followed by the 9-digit number with no spaces. Example: +34913456789 for a Madrid landline or +34612345678 for a mobile number.

Q: How do I handle number portability in my database? A: Store numbers in E.164 format and avoid making assumptions about carriers based on prefixes. Use carrier lookup APIs if you need current carrier information.

Q: Are there restrictions on international calling from Spain? A: No general restrictions exist, but some premium numbers (901, 902) may be blocked by international carriers. Always provide freephone alternatives.

Q: What's the difference between 800 and 900 freephone numbers? A: Both are freephone, with costs borne by the recipient. The distinction is largely administrative; both function identically for callers.

Q: How do I comply with Spain's 3-minute customer service rule? A: Implement call routing optimization, sufficient staffing, and 24/7 availability for incident reporting. Monitor that 95% of calls reach a human within 3 minutes.

Conclusion

This guide provides a comprehensive overview of Spanish phone number formats. By understanding the structure, regulations, and best practices outlined here, you can develop telecommunications applications that are both robust and compliant with Spanish regulations. Remember to:

  • Store all numbers in E.164 format (+34 + 9-digit NSN)
  • Use libphonenumber or equivalent libraries for validation
  • Implement clear cost warnings for premium-rate numbers
  • Ensure freephone access for customer service (legal requirement)
  • Handle number portability correctly
  • Comply with GDPR for all call data and recordings

For the latest regulatory updates, consult the CNMC website and refer to Law 11/2022 (General Telecommunications Act).