How to Format Phone Numbers for Twilio CSV Uploads: Avoid Error 21211 and Wasted Credits
Twilio is unforgiving about phone number formatting. Every number you send to its API must be in E.164 format, which means a plus sign, a country code, and the subscriber number with zero extra characters. No spaces, no dashes, no parentheses, no dots. If you feed Twilio a number like (415) 555-1234 or 415.555.1234, your API call will fail with error 21211, your message will not be delivered, and depending on your setup, you may still be charged for the attempt. If you are uploading a CSV of thousands of contacts to a Twilio-powered campaign, every malformed number is a wasted API call and a wasted cent.
This guide covers exactly what Twilio requires, what goes wrong when you ignore those requirements, how much dirty data actually costs, and how to clean your entire CSV before uploading so that every number lands correctly. If you are running bulk SMS campaigns, appointment reminders, two-factor authentication messages, or any Twilio-powered communication, this is the preparation step that separates campaigns that deliver from campaigns that hemorrhage money.
Twilio's E.164 Requirement: No Exceptions
E.164 is the international telephone numbering standard defined by the ITU. It specifies a maximum of 15 digits, starting with a country code, with no formatting characters. In practice, Twilio requires every phone number to follow this pattern exactly:
- Plus sign prefix: Every number must start with
+. This is not optional. Without it, Twilio cannot determine the country code and will reject the number. - Country code: Immediately after the plus sign. For the US and Canada, this is
1. For the UK,44. For Australia,61. The full list is maintained by the ITU and includes over 200 country codes. - Subscriber number: The remaining digits, with no spaces, dashes, parentheses, dots, or any other non-numeric characters.
- No leading zeros after country code: Some countries use a trunk prefix (leading zero) for domestic dialing that must be stripped in E.164. For example, a UK mobile number dialed domestically as 07911 123456 becomes
+447911123456in E.164.
A US number like (415) 555-1234 must become +14155551234. A UK number like 020 7946 0958 must become +442079460958. An Australian number like 0412 345 678 must become +61412345678. Any deviation from this format and Twilio rejects the number outright.
What Happens When You Send Non-E.164 Numbers to Twilio
Twilio validates the "To" phone number on every API call. If the number is not valid E.164, the API returns an error instead of delivering the message. The specific error depends on what is wrong with the number, but the result is the same: your message is not sent, your workflow is interrupted, and depending on how your code handles errors, you may not even know it failed until a customer complains they never received their confirmation.
Twilio Error Code Reference
| Error Code | Message | Common Cause | Fix |
|---|---|---|---|
| 21211 | Invalid 'To' phone number | Number contains spaces, dashes, parentheses, or is missing the + prefix and country code. Also triggered by numbers that are too short or too long. | Strip all non-digit characters, prepend +country code, validate length per country |
| 21214 | 'To' number is not reachable | The number is syntactically valid E.164 but is not a real, active phone number. Disconnected lines, numbers ported away, or numbers that were never assigned by the carrier. | Remove from list or use Twilio Lookup API to verify before sending |
| 21610 | Message cannot be sent to the 'To' number because the customer has opted out | The recipient previously replied STOP or otherwise opted out of messages from your Twilio number. Twilio blocks the send automatically to comply with TCPA regulations. | Remove opted-out numbers from your campaign list. They must text START to re-subscribe. |
Error 21211 is by far the most common and is almost entirely preventable with proper CSV formatting before upload. Errors 21214 and 21610 require external validation (carrier lookup or opt-out list management), but 21211 is pure data hygiene. If you are seeing 21211 errors in your Twilio logs, the fix is not in your code. The fix is in your data.
The Real Cost of Dirty Phone Data
Twilio charges per message segment. As of 2026, the standard rate for US outbound SMS is approximately $0.0079 per segment. That sounds trivially small until you scale it. Consider a campaign to 50,000 contacts where 15% of the phone numbers are malformed:
- 7,500 failed API calls due to format errors (error 21211)
- $59.25 in wasted Twilio charges if your account is configured to charge for failed attempts (depends on your error handling)
- 7,500 customers who never received your message and have no idea why
- Engineering time debugging why delivery rates are lower than expected
- Potential compliance exposure if those 7,500 contacts were supposed to receive legally required notifications (appointment confirmations, delivery updates, security alerts)
Even when failed sends are not directly charged, they consume API rate limits, slow down your campaign throughput, and generate error logs that obscure real issues. If you are sending 10,000 messages through Twilio and 1,500 fail on formatting, that is 1,500 API calls that took time and bandwidth but produced nothing. Your campaign takes longer to complete, and your logs are cluttered with noise that makes it harder to spot genuine delivery problems.
For recurring campaigns, the costs compound. A monthly newsletter to 50,000 contacts with a 15% bad-format rate wastes $711 per year in failed sends alone, not counting the engineering time spent investigating why delivery rates are underperforming.
Common Phone Number Formats in the Wild
When you export contacts from a CRM, a spreadsheet, or a web form, phone numbers arrive in a staggering variety of formats. Here are the most common patterns you will encounter and why each one fails Twilio validation:
(415) 555-1234— Parentheses and dashes. Human-readable but Twilio rejects it.415-555-1234— Dashes only. Still rejected, no country code, no plus sign.415.555.1234— Dot-separated. A legacy format from business cards. Rejected.415 555 1234— Space-separated. Rejected.4155551234— Digits only but no country code or plus sign. Rejected.14155551234— Includes country code but missing plus sign. Rejected.+1 (415) 555-1234— Has plus and country code but also has formatting characters. Rejected.+1-415-555-1234— Has plus and country code but dashes make it invalid. Rejected.1-800-FLOWERS— Vanity number with letters. Rejected. Must be converted to digits.+14155551234— Correct E.164 format. This is the only one Twilio accepts.
The Bulk Preparation Workflow
Whether you have 500 contacts or 500,000, the workflow for preparing a Twilio-ready CSV is the same. The goal is to transform every phone number into valid E.164 format, remove numbers that cannot be salvaged, and export a clean file that Twilio will accept without a single 21211 error.
Step 1: Export Your Contacts
Pull your contact list from your CRM, marketing platform, or spreadsheet. Export as CSV. Make sure the phone number column is included and that you know which column it is. If your contacts span multiple countries, you also need a country column (or the numbers need to already include country codes). Without country information, there is no reliable way to determine whether 4155551234 is a US number (+1) or some other country's number that happens to be ten digits.
Step 2: Clean with NoSheet
Upload your CSV to NoSheet and select the phone number column. The phone number formatter strips all non-digit characters (parentheses, dashes, dots, spaces), detects the country from the number structure or an accompanying country column, prepends the correct country code with plus sign, and validates the result against E.164 length and format rules. Numbers that cannot be parsed (too short, too long, contain letters, ambiguous country) are flagged for manual review rather than silently corrupted.
Step 3: Validate E.164 Compliance
After formatting, review the validation summary. NoSheet shows you how many numbers were successfully converted, how many were flagged as problematic, and what the specific issues are. Common flags include numbers with too few digits (likely missing area code), numbers with too many digits (likely includes an extension that needs to be stripped), and numbers where the country could not be determined.
Step 4: Remove Invalid Numbers
Filter out or remove numbers that could not be converted to valid E.164. It is better to skip these contacts than to send them to Twilio and generate errors. If the numbers are important, investigate them individually. Often a missing area code can be inferred from other data in the row (city, state, zip code), but this requires human judgment.
Step 5: Deduplicate
Once all numbers are in E.164 format, deduplication becomes trivial because every representation of the same number is now identical. (415) 555-1234, 415-555-1234, and +14155551234 all normalize to +14155551234, making duplicates obvious. Use NoSheet's dedup tool to remove duplicate phone numbers, keeping whichever record has the most complete data.
Step 6: Export and Upload to Twilio
Export the cleaned CSV and upload it to Twilio or your Twilio-integrated application. Every number in the file is now valid E.164, meaning zero 21211 errors, maximum delivery rate, and no wasted API calls.
Why NoSheet's Phone Formatter Is Purpose-Built for Twilio
Generic data cleaning tools treat phone numbers as text strings and offer basic find-and-replace operations. Remove dashes, remove spaces, maybe add a +1 prefix. This works for trivially simple cases but falls apart with international numbers, inconsistent formats within the same column, and edge cases like numbers with extensions or vanity letters.
NoSheet's phone formatter understands phone number structure. It knows that a 10-digit number in a US-context column is a NANP number that needs a +1 prefix. It knows that a UK number starting with 07 is a mobile that needs the leading zero stripped and +44 prepended. It knows that a number starting with 00 is using the international dialing prefix that needs to be replaced with +. It handles these transformations per-number, not per-column, so a column with mixed US and UK numbers gets each one formatted correctly.
The formatter also catches numbers that look valid but are not real. A 10-digit US number starting with 1 in the area code position (like 1235551234) is technically not valid under the NANP because area codes cannot start with 1 or 0. These pass simple length checks but would generate 21214 errors from Twilio. NoSheet flags them before you waste the API call.
For a deeper explanation of the E.164 standard and why it matters beyond Twilio, read our guide on what E.164 format is and why it matters. For step-by-step conversion instructions, see how to convert phone numbers to E.164.
Beyond Formatting: Full Campaign Preparation
Phone number formatting is critical but it is not the only data quality issue that affects Twilio campaigns. Your CSV likely also contains duplicate contacts who would receive the same message twice, outdated names that make personalized messages look wrong, and email addresses that do not match your other systems. A comprehensive pre-campaign cleaning pass should include phone formatting, deduplication, name standardization, and validation of any other fields used in message personalization.
Our guide on data cleaning before a campaign covers the full checklist for preparing contact data for any outreach channel, including SMS through Twilio, email through SendGrid or Mailchimp, and direct mail through print services.
Clean Your Twilio CSV Now
Every malformed phone number in your CSV is a failed API call, a wasted Twilio credit, and a customer who never received your message. The fix takes minutes: upload your CSV, run the phone formatter, validate E.164 compliance, export, and upload to Twilio. Zero errors, maximum delivery, no wasted spend.