---
description: Use trim(), trim_start(), and trim_end() in Rules expressions to remove whitespace or custom bytes from the ends of request values.
title: Remove surrounding bytes with trim functions
image: https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/og.png?v=b9a0cf30bdd926b4
---

[Skip to content](#main-content)

[View RSS feeds](https://developers.cloudflare.com/fundamentals/new-features/available-rss-feeds/) [ Subscribe to RSS](https://developers.cloudflare.com/changelog/rss/index.xml)

[Back to all posts](https://developers.cloudflare.com/changelog)

October 14, 2026

## Remove surrounding bytes with trim functions

[Rules](https://developers.cloudflare.com/rules/)

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Cloudflare Rules supports three new functions for removing surrounding bytes. Use them to remove whitespace before comparing request values. All HTTP products support these functions on all plans:

- `trim()` removes bytes from both ends.
- `trim_start()` removes bytes from the start.
- `trim_end()` removes bytes from the end.

By default, these functions remove ASCII whitespace. An optional constant string specifies a custom set of bytes.

If the input value is nil, these functions return nil.

For example, this expression removes surrounding whitespace before comparing a header value:

```txt
trim(http.request.headers["x-label"][0]) eq "approved"
```

For details, refer to the [`trim()`](https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim), [`trim_start()`](https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim_start), and [`trim_end()`](https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim_end) function references.

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/#page","headline":"Remove surrounding bytes with trim functions","description":"Use trim(), trim_start(), and trim_end() in Rules expressions to remove whitespace or custom bytes from the ends of request values.","url":"https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/","inLanguage":"en","image":"https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/og.png?v=b9a0cf30bdd926b4","dateModified":"2026-10-14","datePublished":"2026-10-14","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
