sendnote.link
Back to blog
tutorials

Share Code Snippets Online with Syntax Highlighting

March 7, 20268 min read

The Developer's Constant Need to Share Code

If you write code for a living, you share code almost as often as you write it. You paste a function into Slack to ask a colleague for feedback. You drop an error traceback into a GitHub issue. You send a configuration block to a teammate who is setting up their local environment. You share a SQL query in a support ticket.

The tools most developers reach for in these moments are imperfect. Slack strips formatting and mangles indentation. Email clients render code in proportional fonts that destroy alignment. Messaging apps collapse whitespace. Even GitHub Gists, which are purpose-built for this, require a GitHub account and several clicks to create.

What developers actually need is dead simple: paste code, get a link, and have the recipient see properly highlighted, correctly indented code when they open it. That is exactly the problem syntax-highlighted code sharing solves.

Why Syntax Highlighting Matters

Syntax highlighting is not a cosmetic luxury. It is a readability tool that directly impacts how quickly someone can understand code. Research on program comprehension consistently shows that color-coded syntax helps developers identify structure, spot errors, and parse logic faster than monochrome text.

Structural Recognition

Highlighting makes the structure of code immediately visible. Keywords stand out from variables. Strings are visually distinct from function names. Comments fade into the background so the active code takes center stage. Without this, the reader has to do the parsing mentally, which is slower and more error-prone.

Error Detection

When syntax highlighting is present, certain classes of errors become visually obvious. An unclosed string literal will cause the highlighting to bleed into subsequent lines. A misspelled keyword will not receive keyword coloring. These visual cues act as a first line of defense.

Language Identification

When you receive a code snippet with proper highlighting, you can often identify the language at a glance based on the color patterns alone. This context helps you shift into the right mental model before you even start reading the code.

Professional Communication

Sharing well-formatted, highlighted code signals professionalism. In code reviews, bug reports, and technical discussions, presentation quality affects how seriously your contribution is taken. A properly highlighted snippet is easier to discuss because everyone can reference the same visual landmarks.

sendnote.link supports Markdown-formatted notes with full syntax highlighting powered by Shiki, the same syntax highlighting engine used by VS Code. This means the code your recipients see is highlighted with the same accuracy and color schemes they are used to in their editor.

Shiki: Editor-Grade Highlighting in the Browser

Most web-based code highlighters use regex-based approaches that approximate syntax highlighting. Shiki takes a different approach — it uses the same TextMate grammars that power VS Code, which means it understands the actual syntax of each language rather than pattern-matching against it. The result is highlighting that correctly handles edge cases like nested template literals, complex generics, and multi-line strings.

sendnote.link runs Shiki on the server side when rendering notes, so the highlighted code is delivered as pre-rendered HTML. This means there is no client-side JavaScript overhead, no flash of unstyled content, and fast load times regardless of snippet length.

Automatic Theme Switching

sendnote.link supports both light and dark themes that follow the reader's system preference. Code blocks automatically switch between a light theme (GitHub Light) and a dark theme (GitHub Dark) using CSS-based switching. Your recipient sees the code in whichever color scheme matches their environment — no manual toggle needed.

Step-by-Step: Sharing a Code Snippet

Here is a complete walkthrough of sharing a code snippet with syntax highlighting on sendnote.link.

Step 1: Open the Editor

Navigate to sendnote.link in any browser. You will see a clean editor ready for input. No signup is required.

Step 2: Write Your Note with a Code Block

Use Markdown fenced code blocks to include your code. Start with three backticks followed by the language identifier, paste your code, and close with three backticks.

For example, to share a TypeScript function:

Here's the utility function for generating unique IDs:

```typescript
import { customAlphabet } from 'nanoid';

const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
const nanoid = customAlphabet(alphabet, 8);

export function generateId(): string {
  return nanoid();
}
```

It uses nanoid with a custom alphabet — lowercase letters and digits only, 8 characters long.

Notice that you can include explanatory text around the code block. This is one of the key advantages of using a Markdown-based tool rather than a pure code paste service — you can provide context alongside the code.

Step 3: Preview the Result

sendnote.link renders Markdown in real time. You can verify that the syntax highlighting looks correct and that the formatting is right before sharing.

Click the share button to generate a unique link. The link is short and clean — something like sendnote.link/a1b2c3d4. Copy it and send it through any channel: Slack, email, Discord, SMS, or wherever your recipient is.

Step 5: Recipient Views the Highlighted Code

When the recipient opens the link, they see the fully rendered note with syntax-highlighted code blocks. The highlighting is baked into the HTML, so it loads instantly with no dependencies on the reader's end.

Supported Languages

Because sendnote.link uses Shiki with TextMate grammars, it supports syntax highlighting for a broad set of languages. Here are some of the most commonly used ones:

  • Web: JavaScript, TypeScript, HTML, CSS, JSX, TSX
  • Backend: Python, Ruby, Go, Rust, Java, C#, PHP
  • Systems: C, C++, Zig, Assembly
  • Data: SQL, GraphQL, JSON, YAML, TOML
  • Shell: Bash, Zsh, PowerShell
  • Config: Dockerfile, Nginx, .env files
  • Markup: Markdown, LaTeX, XML

To activate highlighting for a specific language, include its identifier after the opening backticks. Use python for Python, go for Go, sql for SQL, and so on. If you omit the language identifier, the code block will render as plain monospace text without highlighting.

Practical Tips for Sharing Code

Include Context Around Snippets

A bare code block with no explanation forces the recipient to figure out what they are looking at and why you sent it. Always add a sentence or two above the code explaining what it does and why you are sharing it. Markdown makes this natural.

Use Multiple Code Blocks for Comparisons

If you are showing a before-and-after change, or comparing two approaches, use separate code blocks with explanatory text between them:

The current implementation hits the database on every call:

```python
def get_user(user_id: str) -> User:
    return db.query(User).filter_by(id=user_id).first()
```

Here's the cached version that reduces DB load:

```python
from functools import lru_cache

@lru_cache(maxsize=256)
def get_user(user_id: str) -> User:
    return db.query(User).filter_by(id=user_id).first()
```

This is far more useful than two snippets dumped into a chat window without formatting.

Keep Snippets Focused

Share the relevant portion of the code, not the entire file. If you are asking for help with a specific function, share that function along with any necessary type definitions or imports. Trim out unrelated code so the reader can focus.

Use Burn-After-Read for Sensitive Code

If you are sharing code that contains API keys, database credentials, internal configuration, or proprietary logic, use sendnote.link's burn-after-read feature. The note will be permanently deleted after the first view, ensuring the code does not persist on the web.

Specify the Correct Language Identifier

Using the wrong language identifier, or forgetting to include one, means the highlighting will be wrong or absent. Double-check that you are using the correct identifier for your language. Common mistakes include using js when you mean jsx, or yml when the parser expects yaml.

Comparison with Other Code Sharing Tools

| Feature | sendnote.link | GitHub Gist | Pastebin | Slack Snippet | |---|---|---|---|---| | Account required | No | Yes | Optional | Yes | | Syntax highlighting | Shiki (VS Code quality) | Yes | Basic | Basic | | Surrounding text/context | Full Markdown | Limited | No | No | | Dark/light theme | Auto | Yes | No | Follows app | | Burn after read | Yes | No | No | No | | Expiring links | Yes | No | Yes (paid) | No |

Conclusion

Sharing code should be as simple as writing code. The typical developer workflow of pasting into a message, fighting with formatting, and hoping the recipient can read it is a solved problem. Markdown code blocks with proper syntax highlighting give you readable, correctly formatted code in a shareable link.

sendnote.link combines a Markdown editor with Shiki-powered server-side syntax highlighting, automatic theme switching, and zero-signup sharing. The next time you need to send a code snippet to a colleague, a Stack Overflow answer to a friend, or a config block to a teammate, open sendnote.link, wrap your code in a fenced code block, and share the link. Your code will look exactly as it should.

Ready to share a note?

Create and share notes instantly. No sign-up required.

Create a note