Skip to main content

Url Encode

Encodes a URL string for safe transmission in web requests.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Url - The URL string or text to encode. Cannot be empty.

Options

This node does not have any options.

Outputs

  • Encoded Url - The URL encoded string safe for transmission.

How It Works

The Url Encode node converts text into URL-safe format by encoding special characters. When executed, the node:

  1. Receives text through the Url input
  2. Applies URL encoding (also known as percent-encoding) to escape special characters
  3. Outputs the encoded string through the Encoded Url output

URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits representing the character's ASCII code.

Example Usage

Example 1: Encoding Query Parameters

Encode text for use in URL query parameters:

// Input: "hello world"
// Output: "hello+world"

// Input: "user@example.com"
// Output: "user%40example.com"

Example 2: Encoding Special Characters

Encode a string containing special characters:

// Input: "name=John Doe&email=john@example.com"
// Output: "name%3DJohn+Doe%26email%3Djohn%40example.com"

Example 3: Encoding Search Queries

Prepare search terms for URL parameters:

// Input: "RPA automation & testing"
// Output: "RPA+automation+%26+testing"

Example 4: Encoding Non-ASCII Characters

Encode international characters:

// Input: "Привет мир"
// Output: "%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82+%D0%BC%D0%B8%D1%80"

// Input: "こんにちは"
// Output: "%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF"

Requirements

  • Non-empty string as input

Error Handling

The node will return specific errors in the following cases:

  • ErrInvalidArg - When the input URL is empty

Usage Tips

  • Query Parameters: Always encode parameter values before adding them to URLs
  • Form Data: Encode form field values for application/x-www-form-urlencoded submissions
  • API Requests: Encode user input before including it in API URLs
  • Safe Characters: Only alphanumeric characters and -_.~ remain unencoded
  • Space Encoding: Spaces are encoded as + or %20 depending on context
  • Reversible: Use Url Decode node to retrieve the original text

Common Use Cases

  1. HTTP Requests: Encode query parameters for GET requests
  2. Form Submission: Prepare form data for POST requests
  3. API Integration: Encode search terms or filter values in API URLs
  4. Web Scraping: Build URLs with encoded parameters for web automation
  5. Data URLs: Encode data for data URI schemes
  6. OAuth: Encode callback URLs and parameters in OAuth flows

Characters That Get Encoded

The following characters are encoded:

  • Space: + or %20
  • Special characters: !, @, #, $, %, ^, &, *, (, ), =, +, etc.
  • Reserved characters: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =
  • Non-ASCII characters: All characters outside the ASCII range

Characters That Stay Unencoded

  • Alphanumeric: A-Z, a-z, 0-9
  • Unreserved: -, _, ., ~

Best Practices

  • Always Encode User Input: Never include user input directly in URLs
  • Encode Each Parameter: Encode parameter values individually, not the entire URL
  • Don't Double-Encode: Make sure to encode only once to avoid double encoding
  • Use for Query Strings: Most useful for query string parameters, not URL paths
  • Security: Encoding helps prevent URL injection attacks

Example Workflow

Building a complete URL with encoded parameters:

// Step 1: Define base URL
const baseUrl = "https://api.example.com/search";

// Step 2: Encode parameter values using Url Encode node
const searchTerm = "RPA & automation"; // Input to Url Encode
const encodedSearch = "RPA+%26+automation"; // Output from Url Encode

const category = "software/tools"; // Input to Url Encode
const encodedCategory = "software%2Ftools"; // Output from Url Encode

// Step 3: Build final URL
const finalUrl = `${baseUrl}?q=${encodedSearch}&category=${encodedCategory}`;
// Result: "https://api.example.com/search?q=RPA+%26+automation&category=software%2Ftools"

Common Errors and Solutions

Empty Input

Problem: Error message "URL cannot be empty"

Solutions:

  • Verify the input variable contains data
  • Check if the previous node properly set the output
  • Add conditional logic to handle empty values

Encoding Entire URLs

Problem: The entire URL including protocol gets encoded

Solutions:

  • Only encode the parameter values, not the entire URL
  • Build the URL by combining the base URL with encoded parameters
  • Encode each query parameter value separately

Double Encoding

Problem: Values are encoded twice (e.g., %2520 instead of %20)

Solutions:

  • Check if the input is already URL encoded
  • Ensure you're not encoding the same value multiple times
  • Use Url Decode first if the input might already be encoded

Comparison with Base64 Encoding

FeatureURL EncodingBase64 Encoding
PurposeSafe URL transmissionBinary to text conversion
Output formatPercent-encodedBase64 alphabet
Use caseURL parametersAPI authentication, file encoding
ReversibleYes (Url Decode)Yes (Base64 Decode)
Size increaseVariable~33%

Notes

  • URL encoding is also known as percent-encoding
  • The encoding follows RFC 3986 specification
  • Spaces can be encoded as either + or %20
  • This node uses query escape encoding (suitable for query parameters)
  • For encoding complete URLs or paths, different encoding rules may apply
  • The encoding is NOT encryption - it's for format compatibility, not security
  • Always decode encoded URLs before displaying them to users