URL encoding guide

Fix a URL with spaces

A URL with literal spaces can look harmless in a note but fail when it is copied into an API request, redirect field, or command line.

Open URL Encode Decode Tool View all tools

What to check first

The safest fix depends on where the space appears. A space inside a search value is different from a space inside a full callback URL that will be nested inside another URL.

Example

Input

https://example.com/files/monthly report.pdf

Output

https%3A%2F%2Fexample.com%2Ffiles%2Fmonthly%20report.pdf

Fix the value step by step

  1. Identify the part of the URL that contains a space.
  2. Encode that value with the URL Encode Decode Tool.
  3. If the value is part of a larger URL, paste the encoded piece back into place and keep the rest unchanged.

Why browser behavior can mislead you

A browser address bar is forgiving. It may quietly repair spaces when you press Enter, but an API field, webhook setting, or command line argument may not do that repair for you.

If a URL will be stored, sent to another service, or embedded as a parameter, check the encoded text directly instead of relying on how it looked after opening in a browser.

Common mistakes

  • Assuming a browser's address bar fix is the same as an API-safe value
  • Encoding ampersands in the wrong layer of a query string
  • Sharing a URL copied from rich text that hides the real raw link
  • Fixing spaces but missing other unsafe characters in the same value

Related problems

FAQ

Why does my browser open a URL with spaces?

Browsers often repair typed URLs. Other systems, such as APIs and config fields, may require the encoded text explicitly.

Should I encode slashes too?

Encode slashes when the whole URL is being used as a value inside another URL. Do not encode structural slashes when editing a normal URL by hand.

Can this fix other unsafe URL characters?

Yes. Encoding handles spaces and other characters that need escaping inside URL values.