sed Online

Write or build a sed script, see the output as you type, and copy the exact terminal command. Runs in your browser.

Runs in your browser. Nothing is uploaded.

Updated

sed scriptRuns in your browser · GNU sed syntax
Build a command without knowing sed

Output

6 lines
Run it in your terminal
sed 's/name=/user: /' input.txt
Your text stays on this device. No upload required.

How to use sed Online

  1. Type a sed expression, or use "Build a command" to create one.
  2. Paste your input text and tick -n or -E if you need them.
  3. Check the output, then copy the result or the sed command.

sed Online at a glance

Typical use: Delete comment lines and blank lines from a config file with /^#/d and /^$/d.

Follows GNU sed. Commands that read or write files or run programs (e, r, w) are not available. Your text never leaves your browser.

When to use sed Online

Test a sed script on sample text before you run it on real files, learn how a command behaves, or get a working command without memorising the syntax. Results update as you type, and the exact terminal command is shown under the output.

It follows GNU sed (the version on Linux) and runs entirely in your browser, so your text is never uploaded. Our test suite checks it against real GNU sed output.

sed Online examples

  • Replace on every line: s/http:/https:/g
  • Delete comments and blank lines: /^#/d then /^$/d as two expressions.
  • Print lines 10 to 20: tick -n and use 10,20p.
  • Swap two words: tick -E and use s/([a-z]+) ([a-z]+)/\2 \1/.
  • Join all lines with commas: :a;N;$!ba;s/\n/,/g

sed cheat sheet

CommandWhat it does
s/old/new/Replace the first match on each line. Flags: g all, 2 the second, I ignore case, p print.
/re/d, /re/!dDelete lines that match (or don't match).
3,7p, $pPrint lines 3–7, or the last line (use with -n).
/re/i text, /re/a textInsert a line before, or append one after, matching lines.
y/abc/xyz/Swap characters one for one.
5q, =Stop after line 5; print line numbers.
&, \1, \U…\EIn a replacement: the whole match, a group, upper case.
N, h/G, :a/baRead the next line, use the hold space, loop with labels.

Differences from GNU sed

  • Commands that read or write files or run programs (e, r, w, s///e, s///w) are not available.
  • With alternatives such as a\|ab, the first alternative that matches wins, not the longest one.
  • The M (multi-line) flag and the l command are not supported yet.
  • On a Mac, the built-in sed is BSD sed, which differs from GNU sed. Install GNU sed with brew install gnu-sed and run it as gsed.

References

Frequently asked questions

Is my text uploaded?

No. The script runs in your browser and nothing is sent to a server.

Which sed does it follow?

GNU sed, the version on most Linux systems. The test suite compares its output with real GNU sed on more than 80 cases.

What do -n and -E do?

-n stops sed from printing every line automatically, so only lines printed by p or s///p appear. -E switches to extended regular expressions, where +, ?, ( ) and | work without backslashes.

Why does my command behave differently on a Mac?

macOS ships BSD sed, which has different options and fewer features. Install GNU sed with Homebrew (brew install gnu-sed) and use gsed instead of sed.

Can I edit a file in place?

In a terminal, add -i to edit files directly, for example sed -i 's/old/new/g' file.txt. Keep a backup first. This page shows the output without changing any file.