How to Share Code With ChatGPT or Claude via a Link

Handing a long file to ChatGPT or Claude by pasting it into the chat box often breaks the formatting and eats your message limit. Sharing a link to a clean snippet — or grabbing its raw text — is tidier and keeps the code intact.

Two ways to get code in front of an AI

  1. Share a link: paste your code into the code share tool, create the link, and drop it into the chat with your question.
  2. Use the raw text: open the snippet's raw link to get clean plain text you can copy back without any formatting artefacts.

Keep it focused

AI tools do better with the relevant code than a whole repository. Share the function, the failing test, or the config block — not everything. A line-numbered view also lets you say "explain line 20" precisely.

One privacy note

A shared snippet is reachable by anyone with the link, so do not paste secrets, keys, or customer data into something you then share publicly. The same caution applies when you share a screenshot with ChatGPT. For everyday snippets, a link is the quickest way to get code in front of an AI — free, no account, and the link stays put.

← All posts