空白清理器

通过移除多余空白和空行来整理文本。

// about

工具介绍

一键清理文本或代码中重复的空格、制表符(Tab)以及多余的空白行。让您的文章结构规范,同时减少无谓的文件体积。

如何使用

  1. 将需要清理的混乱文本粘贴到输入框中。
  2. 根据需要勾选“移除空行”等清理选项。
  3. 点击“运行”并复制干净规整的文本。

人们为何使用此工具

  • 数秒内自动消除连续多余空格与空白行。
  • 快速整理从网页或 PDF 复制过来的乱序文本。
  • 无需手动逐个按退格键删除,大幅提升效率。

常见问题解答 (FAQ)

这会把单词之间正常的空格也删掉吗?

不会,它只会把连续重复的多个空格合并为一个正常空格。

可以用来清理代码文件吗?

当然可以!非常适合清除代码中的行尾空格和冗余空行。

粘贴的文本长度有限制吗?

没有限制,长篇文章或大段数据均可流畅处理。

指南 · 数据 · 约 3 分钟

CSV 与 JSON:如何选择,以及转换时要注意什么

把电子表格导出的数据发给 API,或在 Excel 中打开 API 响应,都需要在 CSV 和 JSON 之间转换。了解两种格式的差异,可以避免数据在转换中受损。

CSV(逗号分隔值)是一张表。第一行是列名,之后每一行是一条记录,值之间用逗号分隔。它是存储扁平数据(每行列都相同)最简单、最轻量的方式。

name,city,score
Kim,Seoul,92
Lee,Busan,85

[
  {"name": "Kim", "city": "Seoul", "score": 92},
  {"name": "Lee", "city": "Busan", "score": 85}
]
CSV 与 JSON 的结构差异、Excel 打开 UTF-8 CSV 为何乱码、逗号和引号的转义规则,以及如何把嵌套数据展平。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "空白清理器" that meets the requirements below.

## Goal

Build a tool that cleans up extra spaces, blank lines and line breaks in text.

## Core features

- Trim leading and trailing spaces
- Collapse repeated spaces
- Remove blank lines
- Join lines with spaces
- Handle tabs, non-breaking spaces and full-width spaces

## Inputs

- Text to clean
- Checkboxes for each rule

## Outputs

- Cleaned text
- Number of characters removed

## Edge cases and handling rules

- Option to preserve indentation for code
- Mixed CRLF and LF line endings
- Option to remove zero-width spaces (U+200B)
- Performance on very long text

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- '  a   b  ' becomes 'a b'
- Removing blank lines leaves none
- Non-breaking spaces become normal spaces

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-whitespace-remover/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-whitespace-remover
description: Use when building or changing a 空白清理器 tool. Build a tool that cleans up extra spaces, blank lines and line breaks in text.
---

# Build: 空白清理器

## Goal

Build a tool that cleans up extra spaces, blank lines and line breaks in text.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Trim leading and trailing spaces
- Collapse repeated spaces
- Remove blank lines
- Join lines with spaces
- Handle tabs, non-breaking spaces and full-width spaces

## Inputs

- Text to clean
- Checkboxes for each rule

## Outputs

- Cleaned text
- Number of characters removed

## Rules

- Option to preserve indentation for code
- Mixed CRLF and LF line endings
- Option to remove zero-width spaces (U+200B)
- Performance on very long text
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] '  a   b  ' becomes 'a b'
- [ ] Removing blank lines leaves none
- [ ] Non-breaking spaces become normal spaces

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。