---
title: Sanitize URL
description: "This custom command validates and sanitizes a given URL string, ensuring it is well-formed and safe for use. It trims any whitespace, validates the URL format, and returns a sanitized version as a string. If the input is invalid, it…"
url: "https://legacy.rtila.com/docs/sanitize-url/"
updated: "2025-01-05"
category: Custom Commands
---

# Sanitize URL

This custom command validates and sanitizes a given URL string, ensuring it is well-formed and safe for use. It trims any whitespace, validates the URL format, and returns a sanitized version as a string. If the input is invalid, it throws an error with a descriptive message.    ******How to configure and use this Custom Command**** :**     ![](https://legacy.rtila.com/wp-content/uploads/2024/12/Sanitize-URL.png)

1) Pass a raw URL to sanitize.    ****Watch Video Demo****:  [![](https://legacy.rtila.com/wp-content/uploads/2024/11/Sanitize-URL-1.jpg)](https://youtu.be/ADe4M4Ka2d0)
