去除空格 | 轻松去除多余空格
使用在线去除空格工具,快速清除文本中的多余空格。粘贴文本,点击去除,获得整洁字符串。
主要功能
实时处理
使用自动处理模式即时清理文本
智能清理
选择移除重复空格或所有空格
隐私优先
所有处理都在您的浏览器中进行
最佳用例
数据清理
- • CSV 文件准备
- • 数据库导入
- • Excel 数据格式化
- • 日志文件分析
内容格式化
- • 网站内容清理
- • 电子邮件模板格式化
- • 文档标准化
- • 复制粘贴文本清理
代码优化
- • HTML 压缩
- • JavaScript 清理
- • CSS 格式化
- • 代码可读性提升
使用方法
- 在左侧输入框中粘贴或输入您的文本
- 选择您偏好的清理模式:
- "移除重复空格" - 保留单词间的单个空格
- "移除所有空格" - 移除所有空格,保留换行
- 启用“自动处理”以获得即时结果,或单击“清理文本”手动处理
- 使用复制或下载按钮保存您清理后的文本
可以删除哪些内容
| 选项 | 作用 |
|---|---|
| 多余的空格 | 将多个空格合并为一个空格 |
| 首尾空格 | 修剪每行开头和结尾的空格 |
| 所有空格 | 删除文本中的每个空格 |
| 空行 | 删除段落之间的空行 |
| 制表符 | 删除制表符或将其转换为空格 |
清理空白可使文本在文档、代码和电子表格中保持一致。
从你的AI智能体调用此工具
免费的JSON API和Model Context Protocol (MCP) 服务器。无需注册、无需API密钥、CORS开放。专为Claude、ChatGPT、Cursor、脚本和前端应用设计。
curl -X POST https://mate.tools/api/v1/text-cleanup.php \
-H "Content-Type: application/json" \
-d '{"text":" hello world \n\n\n hello world ","operations":["trim","collapse_spaces","dedupe_lines"]}' import urllib.request, json
req = urllib.request.Request(
"https://mate.tools/api/v1/text-cleanup.php",
data=json.dumps({"text":" hello world \n\n\n hello world ","operations":["trim","collapse_spaces","dedupe_lines"]}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as r:
print(json.load(r)) const r = await fetch("https://mate.tools/api/v1/text-cleanup.php", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({"text":" hello world \n\n\n hello world ","operations":["trim","collapse_spaces","dedupe_lines"]}),
});
console.log(await r.json()); 添加到 claude_desktop_config.json(Claude Desktop)、~/.cursor/mcp.json(Cursor)或任何其他MCP兼容客户端:
{
"mcpServers": {
"mate-tools": {
"command": "npx",
"args": ["-y", "@mate-tools/mcp-server"]
}
}
} 如何删除文本中的多余空格?
删除空格工具通过删除多余的空格、制表符和空行来清理文本 — 适用于整理从 PDF、Word 或 Excel 粘贴的内容。可选择合并双空格、修剪每一行或删除所有空格。