pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

number-lines Add line numbers

Aa Text
Input0 chars
Output0 chars

Flags

--start number default: 1

Examples

Add line numbers to a code snippet

Usage
"const x = 1;
const y = 2;
return x + y;" | number-lines

Number quiz questions for a worksheet

Usage
"What is the capital of France?
Name three prime numbers.
Def..." | number-lines

Number steps in a procedure document

Usage
"Open the admin panel
Click Settings > Users
Select the targe..." | number-lines
View source
(input, opts = {})=>{
                const start = parseInt(opts.start) || 1;
                const lines = input.split("\n");
                const pad = String(lines.length + start - 1).length;
                return lines.map((l, i)=>`${String(i + start).padStart(pad, " ")}  ${l}`).join("\n");
            }