ข้อความ
Whitespace & Trim Tools
ล้างช่องว่างส่วนเกิน: ตัดช่องว่างที่ขอบบรรทัด รวมช่องว่างที่ซ้ำกัน ลบบรรทัดว่าง แปลงแท็บ ↔ ช่องว่าง
Extra whitespace — at line edges, doubled up inside text, blank lines, mixed tabs and spaces — is rarely visible at a glance, but it often breaks string comparisons, parsing, or how code looks. This tool cleans up such issues with a set of targeted operations.
How to use it
- Trim: strip whitespace from the start and end of every line.
- Collapse: replace several consecutive spaces or blank lines with a single one.
- Tabs ↔ spaces: convert in either direction with a chosen number of spaces per tab.
Common uses
- Cleaning up text copied from a PDF or Word document, which often leaves extra spaces and invisible characters behind.
- Normalizing code indentation to one consistent style (spaces only or tabs only) before a commit.
- Debugging why two visually identical lines aren't equal when compared — often the cause is a hidden extra space or a non-breaking space.
Things to keep in mind
A non-breaking space ( , code point U+00A0) looks like a regular space but is a different character to a computer — strings containing it aren't equal to a regular space in comparisons.
Trimming line-edge whitespace doesn't touch spaces inside words or sentences — collapsing repeated internal spaces is a separate operation.
คำถามที่พบบ่อย
การตัดช่องว่างขอบกับการยุบช่องว่างซ้ำต่างกันอย่างไร?
การตัดช่องว่างขอบจะลบเฉพาะช่องว่างต้นและท้ายของแต่ละบรรทัด ส่วนการยุบช่องว่างซ้ำจะแทนที่ช่องว่างติดต่อกันหลายตัวในบรรทัดเดียวด้วยช่องว่างเดียว โดยไม่แตะขอบ
บรรทัดว่างและการแปลงแท็บ/ช่องว่างถูกจัดการอย่างไร?
คุณสามารถลบบรรทัดว่างทั้งหมด หรือยุบเฉพาะบรรทัดว่างติดต่อกันให้เหลือหนึ่งบรรทัด และแปลงแท็บเป็นช่องว่างหรือกลับกันโดยกำหนดความกว้างแท็บได้
ข้อความที่วางถูกส่งไปยังเซิร์ฟเวอร์หรือไม่?
ไม่ การทำความสะอาดเกิดขึ้นทั้งหมดในเบราว์เซอร์ของคุณด้วย JavaScript ไม่มีข้อมูลใดถูกส่งไปที่อื่น
อักขระความกว้างศูนย์คืออะไร?
คืออักขระ (zero-width space, zero-width joiner ฯลฯ) ที่ไม่กินพื้นที่บนหน้าจอเลย แต่ยังคงอยู่ในข้อความในฐานะอักขระแยกต่างหาก บางครั้งติดมากับข้อความเมื่อคัดลอกจากบางเว็บไซต์ และอาจทำให้การเปรียบเทียบสตริงหรือการค้นหาพังโดยไม่รู้ตัว
ทำไม non-breaking space ถึงดูเหมือนช่องว่างธรรมดา แต่ทำงานต่างกัน?
Non-breaking space ( ) มองด้วยตาเหมือนช่องว่างธรรมดาทุกประการ แต่สำหรับคอมพิวเตอร์แล้วมันเป็นอักขระคนละตัว — สตริงที่มีช่องว่างสองแบบนี้จึงไม่เท่ากันในทางเทคนิคเมื่อเปรียบเทียบ แม้จะดูเหมือนกันบนหน้าจอก็ตาม