%27 is the URL-encoded apostrophe (').

In a URL, %27 stands for the apostrophe ('). Here is when to encode it, what it does in each part of a URL, and what every major language outputs.

Quick facts

Character'
NameApostrophe (single quote)
UnicodeU+0027
UTF-8 bytes27 (1 byte)
Percent-encoded%27
Lowercase form%27 — identical meaning
Double-encoded%2527
HTML form encoding%27
RFC 3986 classReserved — sub-delimiter
HTML entity'

What it means in a URL

The apostrophe is a sub-delimiter. encodeURIComponent, Java and Ruby’s form encoder leave it raw; PHP, Python, Go and C# encode it as %27. A raw apostrophe in a URL placed in single-quoted HTML or JavaScript ends the string.

RFC 3986 class: Reserved — sub-delimiter. RFC 3986 allows it raw in paths and queries, but some schemes and servers give it meaning, so encoding it as data is the safe choice.

When to encode it

Where it appearsWhat to do
Path segmentAllowed raw (encoding is also fine)
Query valueAllowed raw (encoding is also fine)
FragmentAllowed raw
Form bodyEncode

The mistake to watch for

SQL-injection filters and WAFs that flag %27 in legitimate names such as O’Brien — and code that inserts a raw ' into a single-quoted attribute.

What each language produces

Left as-is by JavaScript encodeURIComponent(s), JavaScript encodeURI(s); every other function in the table encodes it. Output for the single character, UTF-8 input, tested against the real runtimes (see the encoding comparator for your own strings).

FunctionOutput
JavaScript encodeURIComponent(s)'kept
JavaScript encodeURI(s)'kept
JavaScript URLSearchParams%27encoded
Python urllib.parse.quote(s)%27encoded
Python quote(s, safe="")%27encoded
Python urllib.parse.quote_plus(s)%27encoded
PHP rawurlencode($s)%27encoded
PHP urlencode($s)%27encoded
Java URLEncoder.encode(s, UTF_8)%27encoded
Go url.QueryEscape(s)%27encoded
Go url.PathEscape(s)%27encoded
Ruby URI.encode_www_form_component(s)%27encoded
Ruby ERB::Util.url_encode(s)%27encoded
C# / .NET Uri.EscapeDataString(s)%27encoded

Decoding it

decodeURIComponent('%27') returns the apostrophe ('). Python: urllib.parse.unquote('%27'); PHP: rawurldecode('%27'). Paste any string into the URL decoder to decode it in your browser.

← %26 Ampersand  ·  Full URL encoding table  ·  %28 Left parenthesis →

Common questions.

%27 is the percent-encoded form of the apostrophe ('), whose byte value is 0x27. Decoding the URL turns it back into the character.

Yes. Hex digits in percent-encoding are case-insensitive, so %27 and %27 mean the same thing. RFC 3986 recommends uppercase, and mixing cases can make caches and analytics count one URL as two.

Use your language’s encoder on the value: encodeURIComponent in JavaScript gives ', Python’s quote(s, safe="") gives %27, PHP’s rawurlencode gives %27.

More from the toolkit.

About this page. Written and maintained by Sri Murugan Systems, the developer of urlencodedecode.com. Character classes follow RFC 3986 §2; language outputs were generated by running each function in its real runtime.