How to Share Code Between Devices Without Losing Formatting
You wrote some code on your laptop and now you need it on your phone — or you're helping someone and want to send them a snippet that actually runs when they paste it. Sounds trivial. Then you email it to yourself, paste it out, and the indentation is gone, the quotes turned curly, and a long line wrapped into three. Let's fix that for good.
Why code breaks in transit
Most everyday apps are designed for prose, not source code. When you send a snippet through them, a few things tend to happen:
- Smart quotes: straight
"and'become “curly” characters that your compiler rejects. - Lost indentation: tabs and leading spaces get collapsed, so structure disappears.
- Line wrapping: long lines get hard-wrapped, silently splitting statements.
- Auto-linking: anything that looks like a URL becomes a link mid-code.
None of these are visible until you try to run the result. The trick is to move code through something that treats it as exact text.
The reliable methods
1. Use a pasteboard with a short code
This is the fastest cross-device method. Paste your snippet into a tool like KuickPaste, and it returns a 6-character code. Type that code on the other device and the snippet appears byte-for-byte, with syntax highlighting on top. No copy-paste bridge, no cable, no account. It also preserves whitespace exactly, which is the whole point.
2. A private repo or gist
If the code is part of a project you already track, committing to a private branch or gist works — but it's heavier for a one-off, requires an account, and isn't great for quickly reading on a phone.
3. Cloud notes with monospace
Some note apps preserve formatting if you use a code block. It works, but you're trusting each app's editor not to “helpfully” reformat, and syncing can lag.
The quickest workflow
For a genuine one-off transfer, the pasteboard route wins on speed and fidelity:
- Paste the snippet on device A and press Create Paste.
- Note the 6-character code (e.g.
x7Qk2p). - On device B, enter the code in the Get box. Done.
If the code is sensitive, add a password or set it to burn after reading so it deletes itself once retrieved.
Rule of thumb: if a snippet needs to run after the trip, move it through something that preserves exact text — not a chat box.
Wrapping up
Sharing code between devices doesn't have to be a game of “spot the broken quote.” Pick a method that treats your snippet as exact text, and formatting problems disappear. For most quick transfers, a pasteboard with a short device code is the least-friction option.
Want the full walkthrough with screenshots of each step? See the device-sync guide, or jump straight to the tool and create a paste.