URL Encode Pipe Character (|)

Learn how to URL encode the pipe/vertical bar character (|) as %7C. Common in API parameters for multi-value fields and OR-style filters.

Character

|

Encoded

%7C

Detailed Explanation

The pipe character (|), also known as the vertical bar, is not a reserved character under RFC 3986 but is classified as unsafe and should be encoded as %7C in URLs for maximum compatibility.

Percent-encoded form: %7C represents the pipe character (ASCII code 124, hexadecimal 0x7C).

Why encoding is recommended: Although the pipe is not reserved for any structural purpose in URLs, it falls outside the "unreserved" character set (which only includes A-Z a-z 0-9 - _ . ~). Many systems handle bare pipes inconsistently:

  • Some email clients break URLs at the pipe character
  • Certain proxies and CDNs reject or modify URLs containing pipes
  • Shell scripts that pass URLs as arguments may interpret | as a command pipe
  • Markdown link parsers often break at | characters in URLs

JavaScript behavior:

encodeURIComponent("|")            // "%7C"
encodeURIComponent("red|blue|green") // "red%7Cblue%7Cgreen"
encodeURI("|")                     // "%7C"

// Both encodeURI and encodeURIComponent encode the pipe

Common scenarios where pipes appear in URLs:

  • Multi-value API parameters: ?colors=red|blue|green (pipe as OR/delimiter)
  • Wikipedia and MediaWiki URLs: template parameters use pipes extensively
  • Image transformation services: ?transform=resize|100x100|crop
  • Search APIs with OR operators: ?q=javascript|typescript
  • Data pipeline or ETL tool interfaces

API design note: Some APIs use pipes as value delimiters instead of repeated parameters or comma separation. While this works when properly encoded, it is a non-standard convention. If you design an API, consider using comma-separated values or repeated parameter keys instead, as these are more universally supported and less likely to cause encoding issues.

Pitfall: When pipes appear in URLs shared via communication tools (Slack, Teams, email), the URL is frequently broken or truncated at the pipe character. If your application generates shareable URLs, always encode pipes. Better yet, avoid pipes in user-facing URLs altogether and use a different delimiter convention for multi-value parameters.

Use Case

Building API filter queries with multiple values using pipe delimiters, such as retrieving products in multiple categories: /api/search?category=electronics%7Cclothing%7Cbooks.

Try It — URL Encoder

Open full tool