Skip to content

Main content

Line Ending Final Newline Flag Tool

Identify the final CRLF, LF, or CR newline sequence without normalizing the text.

Loading tool…

Description

Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.

Text layout distinguishes Unicode characters, encoded bytes, and visual columns. These counts need not agree: a tab depends on its column position, while a newline is a sequence of characters with a particular spelling.

Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.

When to use this tool

Use Line Ending Final Newline Flag when you need one deterministic text-layout or encoding component under the stated counting convention.

How to use the tool and how it works

  1. Enter text. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read hasFinalNewline, ending. Inspect hasFinalNewline before interpreting the associated values.

Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.1

Input fieldMeaning and unitsAccepted input
textSupplied text; only the transformations stated above are applied.Required. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
hasFinalNewlineHas Final NewlineRequired. Boolean.
endingEndingRequired. Text; maximum UTF-16 length 8192.
json
{
  "input": {
    "text": "alpha\r\n"
  },
  "output": {
    "hasFinalNewline": true,
    "ending": "CRLF"
  }
}

Limitations and assumptions

  • Only the final ending is classified; internal or mixed line endings and text encoding are not inspected.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Inspect the final text in the target encoding and renderer when display width or line wrapping matters.

References

  1. Calculation and input contract: text/line-ending-final-newline-flag — tool.io

Similar or alternative tools

  • Hymn Stanza Line Count

    Normalize CRLF and CR to LF, split into lines, and remove one final empty split item.

  • Text Tab Stop Width

    Advance by tabSize - currentColumn modulo tabSize and return the resulting nextColumn.