Choose the display from the task

A confirmation screen may show only a country code and final digits, such as +44 •••• ••0018. A support workflow may need more context but should reveal the full value only after an authorized action. Do not use one masking rule everywhere without considering what a user must recognize.

Apply masking to the rendered copy, not the stored canonical value. Replacing database digits with asterisks destroys the identifier and can break future verification or account recovery.

Keep full numbers out of routine logs

Request bodies, validation errors, URLs, analytics events and exception traces can all capture phone values accidentally. Log a stable internal record identifier, operation result and country instead. If correlation is necessary, use a purpose-specific pseudonymous token and manage its secret and retention separately.

The OWASP Logging Cheat Sheet recommends removing, masking, sanitizing, hashing or encrypting personal data where it should not be recorded directly.

Do not put phone numbers in URLs

Query strings and paths commonly appear in browser history, access logs, referrer data and monitoring systems. Send phone input in an appropriate request body over HTTPS and configure observability tooling to redact sensitive fields before export.

Mask consistently at every boundary

  • Admin tables and customer-support views.
  • Application, proxy and provider logs.
  • Analytics properties and event parameters.
  • Error reporting and session replay.
  • Exports, screenshots and notification previews.

Test redaction with nested objects, alternate field names and failure paths. The error path is often where raw input leaks.

Masking is only one control

Limit collection, restrict full-value access, encrypt data in transit and at rest where appropriate, audit exports and delete data when its documented purpose ends. The exact legal obligations depend on jurisdiction and use case; review them with qualified counsel rather than treating a UI mask as compliance.

For the underlying record shape, see how to store phone numbers in a database.