---
title: "Collapse Whitespace"
description: "Local-first visual environment for building and running AI workflows. Build agents visually, deploy anywhere, privacy by design."
canonical: https://docs.nodetool.ai/nodes/nodetool/text/collapsewhitespace
markdown: https://docs.nodetool.ai/nodes/nodetool/text/collapsewhitespace.md
product: NodeTool
source: https://github.com/nodetool-ai/nodetool/blob/main/docs/nodes/nodetool/text/collapsewhitespace.md
---

# Collapse Whitespace

**Type:** `nodetool.text.CollapseWhitespace`

**Namespace:** `nodetool.text`

## Description

Collapses consecutive whitespace into single separators.
    text, whitespace, normalize, clean, remove

## Properties

| Property | Type | Description | Default |
|----------|------|-------------|---------|
| text | `str` |  | `` |
| preserve_newlines | `bool` | Keep newline characters instead of replacing them | `false` |
| replacement | `str` | String used to replace whitespace runs | ` ` |
| trim_edges | `bool` | Strip whitespace before collapsing | `true` |

## Outputs

| Output | Type | Description |
|--------|------|-------------|
| output | `str` |  |

## Related Nodes

Browse other nodes in the [nodetool.text](./) namespace.
