小匠工具箱

Text Aligner / 在线文本对齐

Text Aligner 是免费在线文本对齐工具(text alignment generator),可将多行纯文本左对齐、右对齐、居中或两端对齐。自动按最长行计算宽度,也可指定行宽、自定义左右填充字符,并复制或下载保留空格的 TXT。所有处理都在浏览器本地完成。

开始使用 文本对齐 ↓

文本对齐适合做什么?

  • Center text online:居中排列多行标题、诗句或名单
  • 为 README、代码注释和纯文本公告制作字符横幅
  • 左对齐或右对齐文字,在等宽字体中统一行尾位置
  • 两端对齐英文段落,将空格均匀分配到单词之间
  • 按显示列宽处理中文、日文、韩文与英文混排
  • 导入 UTF-8 文本并下载可直接使用的对齐结果

主要功能

  • 四种对齐模式,自动匹配最长行或指定 1–1000 列行宽
  • 独立设置左右填充字符,选择居中余出的字符放在哪一侧
  • 支持按可见字符分组计数或估算显示列宽,避免拆开组合字符和 Emoji
  • 可选长行换行、首尾空白清理及空格可视化,保留空行
  • 实时预览、四种可操作示例、UTF-8 文件导入、复制和 TXT 下载
  • 文本在本地处理,无需账户,最多支持 100,000 个输入字符

How to align text online / 如何在线对齐文本

Paste your text or import a UTF-8 text file, then choose Left, Center, Right or Justify. Use the longest line as the automatic width, or enter a fixed width from 1 to 1000 columns. Copy the result or download a TXT file with the padding preserved. This free text alignment generator runs locally in your browser; no account is required.

粘贴文本或导入 UTF-8 文件,选择对齐方式。默认按最长行自动计算宽度;也可以关闭自动宽度,输入固定行宽。长行默认完整保留,启用自动换行后优先在空白处分行,连续长单词按可见字符分组断开,最后复制或下载 TXT。空行会保留。

Center text with custom padding / 自定义填充与居中

For centered text, the remaining columns are split between both sides. If the padding is odd, choose which side receives the extra character. Use different single printable ASCII characters on the left and right to create banners, or leave both fields empty for spaces. Justify distributes spaces between words; a line with only one word stays unchanged.

居中会把剩余宽度分配到两侧,可指定余出的一个字符放在左边还是右边。左右可独立使用空格、短横线、点号等单个可打印 ASCII 字符;两端对齐只调整单词之间的空格,单个单词不会被强行拆开。上方四个示例可直接载入并调整参数。

Plain text alignment vs CSS text-align / 纯文本与网页排版

This tool inserts real characters into plain text. View the output in a monospace font, a preformatted block or a Markdown code block. HTML normally collapses repeated spaces: use white-space: pre or pre-wrap to preserve them. For visual alignment of a web paragraph without inserting characters, use the CSS text-align property instead.

显示列宽是近似估算:英文通常占 1 列,中日韩宽字符和多数 Emoji 约占 2 列,组合重音与 Emoji 分组不会被拆开。不同字体、双向文字或应用程序可能显示不同;按字符数模式则每个可见字符分组计为 1。Tab 会按每 4 列的制表位展开为空格。

使用示例

Center text online / 多行居中

输入:输入 cat 和 tools 两行,选择居中与自动匹配最长行。

结果:最长行为 5 列:cat 左右各补一个空格,tools 保持不变。复制结果为 " cat " 和 "tools"。

Custom text banner / 自定义横幅

输入:输入 HELLO,选择居中,固定行宽 11,左右填充均设为短横线。

结果:---HELLO---(共 11 列)。可在上方载入“文字横幅 / Text banner”示例继续尝试。

Justify text / 英文两端对齐

输入:输入 one two three,选择两端对齐,固定行宽 18。

结果:one two three:两个单词间隔分别为 4 和 3 个空格,总宽度正好 18 列。

CJK display width / 中英混排

输入:输入“你好”和“Hi”两行,选择右对齐、显示列宽,固定宽度 6。

结果:“你好”前补 2 个空格,“Hi”前补 4 个空格;两行估算显示宽度均为 6 列。

常见问题

How do I center text online?

Paste your lines, choose Center and keep Use longest line enabled, or enter a fixed line width. The text aligner adds padding on both sides. You can choose the side for an extra character when the padding cannot be split evenly.

Can I left-align, right-align and justify text?

Yes. Choose Left, Center, Right or Justify above. Left and right alignment add padding at the opposite edge. Justify distributes spaces across the gaps between words, while single-word lines remain unchanged.

Is this text alignment generator free and private?

Yes. The tool processes text and imported files in your browser without uploading them. You can copy or download the result without an account. Input is limited to 100,000 characters; very large padded results should be split into smaller batches.

Why does the alignment change after I paste the result?

Some apps collapse spaces or use proportional fonts. Use a monospace font or a Markdown code block. In HTML, preserve spaces with white-space: pre or pre-wrap. The optional dots only visualize spaces; copy and TXT export still contain real spaces.

文本超过指定宽度会被截断吗?

不会。默认完整保留超长行并提示超宽数量;关闭自动宽度后,可以启用长行自动换行。宽字符始终保持完整,因此目标宽度小于单个宽字符时,该字符仍可能超宽。

中文、日文、韩文和 Emoji 如何计算宽度?

显示列宽模式按常见终端规则估算:英文约占 1 列,中日韩宽字符和多数 Emoji 约占 2 列。按字符数模式把一个可见字符分组计为 1。实际效果取决于字体和目标应用,不保证在所有字体中完全一致。

这个工具能做翻译词语对齐或 CAD 文字对齐吗?

本页用于单段或多行纯文本的版式对齐。翻译中的 text alignment 指源语言与译文之间的词语对应关系;CAD 的文字对齐则是沿图形线条排列文字,属于不同用途。此工具不会生成翻译词语对应关系或修改 CAD 文件。

怎样保留原始缩进、空行并导出文本?

取消“去除每行首尾空白”可保留原有行首缩进。空行不会删除,Tab 会展开到每 4 列的制表位。点击复制或 TXT 按钮可保存真实空格;“用圆点显示空格”仅改变预览。输入文件请使用 UTF-8 编码。

同类工具

查看全部文本处理工具 →