PHP urldecode() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
URL

Definition

In PHP, urldecode() turns %XX sequences back into characters and changes every + into a space.

It matches the output of urlencode() and the format used by HTML forms.

Syntax

Call urldecode() with the values you need. Start with this line.

PHP
$text = urldecode($encoded);
CallWhat it does
urldecode("Hello+World")Returns "Hello World".
urldecode("100%25")Returns "100%".

Use it for form and query data. Use rawurldecode() for URL paths where + is a real plus sign.

Library declarations
PHP
urldecode(string $string): string

Parameters

ParameterDescription
stringRequired. The URL-encoded string to decode.

Return Value

Return ValueDescription
stringThe decoded string.

PHP Examples

Example 1 — Decode a Query Value

Turn plus signs and %26 back into a space and an ampersand.

PHP
<?php
$encoded = "Hello+World+%26+Co";

echo urldecode($encoded), PHP_EOL;

How It Works

  1. Start with encoded text. + stands for a space.
  2. Call urldecode(). Each + becomes a space.
  3. %26 becomes &. All %XX codes are decoded.
  4. Print the text. It is now readable.

Example 2 — Decode a Percent Sign

An encoded percent sign is written as %25.

PHP
<?php
$encoded = "100%25+sure";

echo urldecode($encoded), PHP_EOL;

How It Works

  1. Use %25. It is the code for the % sign.
  2. Decode the text. %25 becomes %.
  3. The + becomes a space. So you read 100% sure.
  4. Avoid decoding twice. A second pass could break the % sign.

Example 3 — Decode Accented Letters

UTF-8 letters are sent as several %XX bytes. urldecode() joins them again.

PHP
<?php
$q = "caf%C3%A9+au+lait";

echo urldecode($q), PHP_EOL;

How It Works

  1. Start with encoded bytes. The letter é is %C3%A9.
  2. Call urldecode(). The two bytes are joined.
  3. Plus signs become spaces. You get café au lait.
  4. Use UTF-8 pages. The text then shows correctly.

Frequently Asked Questions

urldecode() decodes a URL-encoded string. It changes %XX codes to characters and + to a space.
urldecode(string $string): string. Pass the encoded text.
urldecode() turns + into a space. rawurldecode() keeps + as a plus sign.
No. PHP has already decoded them. Decoding twice can change values that contain % or +.
Use urlencode() to create text that urldecode() can decode.

Next: urlencode()

urlencode() encodes a string for a URL query, writing spaces as plus signs.

urlencode() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful