How to Share Code Snippets Online Without Breaking the Formatting

How to Share Code Snippets Online Without Breaking the Formatting

Paste 40 lines of Python into a chat and watch what happens: indentation collapses, quotes turn "smart", long lines wrap, and the code no longer runs. The person helping you then has to fix the formatting before they can even read it. Here's how to share code so it arrives exactly as you wrote it.

Choose the right method

MethodBest forDownsides
Inline code block in chat1 to 15 linesGets cramped and hard to discuss line by line when longer
Snippet linkLonger code, logs, configs, anything you'll discussOne extra click to open
Git repository or gistSeveral files, history, collaborationNeeds an account and more setup
ScreenshotShowing what something looks likeCan't be copied, searched or run

How to share a snippet as a link

  1. Copy your code.
  2. Open the free code sharing tool.
  3. Paste the code, choose its language (23 are available, from Bash to YAML), and optionally add a title such as "Login handler, fails on empty email".
  4. Click create and copy the link.

The person you send it to gets a clean page with line numbers, so you can both say "look at line 42", and a raw view that shows only the plain text, ideal for copying or downloading with tools like curl. No account is needed to create or view snippets, and links don't expire.

Before you share: remove secrets

Code often contains more than you notice:

Replace them with placeholders such as YOUR_API_KEY or [REDACTED]. Snippet links are unlisted, but anyone with the link can read them. Config files need extra care; see how to share a config file safely. If a key was ever shared by mistake, rotate it: deleting the message isn't enough.

Make your snippet easy to help with

Where snippet links work well

Why not a screenshot of the code?

Screenshots of code are hard to read on phones, can't be copied, can't be searched, and are invisible to screen readers. Many developer communities discourage them for exactly that reason. Share text, and use a screenshot only for visual output: a rendering bug, a UI state, a chart.

Paste code, pick a language, get a link with line numbers and a raw view. Free, no account, up to 512 KB.

Share a code snippet

Frequently asked questions

What is the best way to share a code snippet?

For a few lines, a code block in your chat app is fine. For anything longer, paste it into a code-sharing tool and send the link: indentation is kept, lines are numbered, and people can copy the raw text.

Why does my code lose its indentation in chat?

Chat apps and email clients collapse spaces, convert quotes to "smart" quotes, wrap long lines and sometimes turn text into links. A code block or a snippet link avoids that.

Should I share code as a screenshot?

Usually no. People cannot copy, search or run code in an image, and screen readers cannot read it. Share text, and use a screenshot only to show how something looks.

How long do shared snippets stay online?

Snippets on sshot.online stay online and links do not expire. Each link uses a random, unlisted code.

Is there a size limit?

Up to 512 KB per snippet, which is thousands of lines of code.

Related articles

← All guides