Text lines count
text-lines-count · version 1.0.0 · Text · free, no key needed
Count exact line multiplicities in first-seen order.
Use when you need to: text lines count · count lines · line histogram.
Supported
- text lines count
- count lines
- line histogram
Not supported
- trim
- case fold
- sort by count
- locale
Behavior
- Split on CR LF, LF, or CR. Do not treat other Unicode separators as line breaks.
- A trailing terminator does not create an extra empty line.
- Empty document -> zero lines, trailing_terminator false.
- A document that is only a terminator -> one empty line, trailing_terminator true.
- A document with no terminator -> last line kept, trailing_terminator false.
- Preserve empty lines in the middle.
- Output reconstruction uses LF. If the result has at least one line, append a trailing LF iff the selected window includes the original trailing terminator or includes a line that was followed by a separator in the source.
- No trimming, case folding, Unicode normalization, or locale rules.
- Each distinct line body gets a count of exact occurrences.
- Items are emitted in first-seen order.
- line values are the parsed bodies without terminators.
Input
text(string, required): max length 256000
Output
items(array of object, required)lines_in(integer, required)unique(integer, required)
Limits
- max input bytes: 256000
- max lines: 10000
Example
Request input:
{
"text": "a\nb\na\n"
}
Response:
{
"result": {
"items": [
{
"line": "a",
"count": 2
},
{
"line": "b",
"count": 1
}
],
"lines_in": 3,
"unique": 2
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "text-lines-count",
"version": "1.0.0",
"input": {
"text": "a\nb\na\n"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/text-lines-count/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"a\nb\na\n"}'
The machine-readable contract is at /v1/tools/text-lines-count/versions/1.0.0.
CLI
node cli.mjs run text-lines-count 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Text count: Count Unicode code points, UTF-16 code units, UTF-8 bytes, and lines.
- Text diff stats: Summarize a line-record diff as keep, insert, delete, and hunk counts.
- Text line diff: Diff two texts as line records, preserving each line terminator.
- Text lines difference: Set difference a minus b using exact line equality.
- Text lines multiset subtract: Multiset subtract b from a: remaining counts, first-seen order from a.
- Text lines multiset union: Multiset sum of two line bags: counts add, first-seen order from a then new from b.