Why sharing code is harder than sharing text
Code is text with strict rules. One changed quote, one missing space in a Python file, a line broken in the wrong place, or a tab turned into spaces, and it stops working or, worse, works differently. Many places where people paste code were built for prose: chat apps, email, document editors and social posts. They “fix” what they think are mistakes. Straight quotes become curly quotes, double spaces collapse, long lines wrap, and underscores or asterisks turn into italics or bold.
Readability matters too. Unhighlighted code is much harder to scan, and keywords, strings and comments are hard to tell apart in a wall of grey text. Syntax highlighting colours those parts so a reader can see the structure at a glance.
Your options, compared
- A chat code block. Most chat tools can format a block as code, usually with triple backticks. It keeps indentation and gives a monospace font, but highlighting varies and long code is awkward to read in a narrow window.
- A gist or paste site. Good for code you want to keep, link to or discuss. They give permanent links, highlighting and sometimes versioning, but they often ask for an account, make you choose visibility and expiry, and may keep the text longer than you want.
- A repository. The right place for real projects and anything others will edit. It is too heavy for a ten-line hand-off.
- A file attachment. Fine when the other person will open it in an editor. Awkward for a quick look, and some systems block certain file types.
- A code clipboard with a short code. For a quick hand-off between devices or people, a code clipboard lets you paste, get a six-digit code, and have the receiver open it highlighted. It keeps text exactly, has no account, and the clip expires by itself.
Share with the code clipboard
- Open the Share Code Online page and paste or type your code. The language is detected, or choose it from the list.
- Choose how long it should last, and add a password or delete-after-first-view if the code is private.
- Press Save to clipboard and send the six-digit code or the link, or let the other person scan the QR code.
- They open it on any device, see the highlighted code, and copy it or download it with the right file extension.
Highlighting is done in the browser, and the language marker travels inside the clip, so with a password even the language is encrypted. The size limit is 100,000 characters per clip.
Keep secrets out of snippets
The most important rule: never share secrets in a snippet. API keys, access tokens, private keys, passwords and connection strings get copied, cached and forgotten. Remove them first, and replace them with placeholders such as YOUR_API_KEY. If you ever pasted a real secret somewhere you do not control, treat it as exposed and rotate it. For other sensitive material, the guide to sharing passwords safely explains one-time messages and what to avoid. Read logs before you paste them, because they often contain addresses, user names and tokens you did not notice.
Make a snippet easy to use
- Share the smallest example that shows the problem or the idea. A minimal snippet gets faster answers.
- Say the language and version if it matters: “Python 3.11” or “Node 20”.
- Include the error message next to the code, as text rather than a screenshot, so it can be searched and copied.
- Keep the indentation style consistent, spaces or tabs, so the code runs when pasted.
- Use a descriptive file name when you download it, and keep the extension.
Sharing between your own devices
Sometimes the other person is you: a command on your phone that you want on a server console, a snippet from a laptop to a lab machine, an error from one computer to another. A short-lived clip is a fast way to do that without logging in anywhere. The guide to sharing code snippets online goes through the options for developers and students, and sending text from a phone to a PC covers moving text across devices in general.
Privacy and expiry
A clip is deleted at the end of the time you choose, at most seven days, and cannot be recovered. Anyone with the code can open an unprotected clip until then, so do not post the code publicly. For private snippets, use a password (the code is then encrypted in your browser before it is sent), and send the password through a different channel.