Pasting ordinary code into ChatGPT, Claude or Gemini is usually fine for open-source or personal projects, but it is not safe for secrets or for code you aren't allowed to share: what you paste is stored by the vendor and, on consumer plans, may be used to train models depending on your settings. Never paste API keys, passwords, customer data or your employer's proprietary code into a personal account; use an approved business plan, the API or a local model instead.
The vendor statements below were checked on the vendors' own pages in October 2026. They change often, so check the current page before relying on them.
What happens to code you paste
A chat message is sent to the vendor's servers, processed, and stored in your conversation history. Three separate things can then happen to it, and they are controlled differently:
- Training: the conversation may be used to improve future models. This is the risk most people mean, and it depends on your plan and settings.
- Retention: the conversation is kept for some period, even if it isn't used for training, for example for abuse monitoring.
- Human review: some conversations, such as ones flagged for safety or ones you rate, may be read by people.
Turning off training doesn't turn off the other two.
What the vendors say (as of October 2026)
| Product | Used for training by default? | What the vendor page says |
|---|---|---|
| Claude consumer plans (Free, Pro, Max) | Your choice in privacy settings | Anthropic uses chats and coding sessions if you "choose to allow us"; Incognito chats are never used; conversations flagged for safety review may be used for safety systems; rated conversations are kept up to 5 years |
| Claude for Work, Anthropic API | No | "By default, we will not use your inputs or outputs from our commercial products" to train models, unless you report feedback or otherwise opt in |
| Gemini Apps (consumer) | Yes, while Keep Activity is on | Activity is used to improve services "including training generative AI models"; a subset goes to human reviewers and is kept up to 3 years; with Keep Activity off, chats are kept 72 hours |
| OpenAI API | No | "data sent to the OpenAI API is not used to train or improve OpenAI models" unless you opt in; abuse-monitoring logs kept up to 30 days by default |
| ChatGPT consumer app | Check your settings | OpenAI's consumer help pages refused automated access when we checked, so we haven't quoted them here; read OpenAI's help article on how your data is used |
The pattern across vendors is consistent: business products and APIs exclude training by default; consumer apps make it a setting, and the default is not always "off". Google's privacy hub states it most bluntly, advising that you "don't enter confidential information that you wouldn't want a reviewer to see."
Never paste these, on any plan
- Secrets: API keys, tokens, passwords, private keys, connection strings,
.envfiles. A key in a chat log is a leaked key. If you've already done it, treat it as exposed and follow what to do when an API key leaks. - Personal data: customer records, logs with email addresses or IPs, database dumps. Sharing these with a third party can break privacy law and contracts, separate from any training question.
- Code you aren't licensed to share: your employer's proprietary code in a personal account, or a client's code under an NDA. Your employment contract and security policy decide this, not the vendor's settings.
- Undisclosed vulnerabilities: details of an unpatched security hole in your product.
Usually fine to paste
- Open-source code that is already public.
- Your own personal projects, if you're comfortable with the vendor's terms.
- Error messages and stack traces, once you've removed paths, hostnames and user names (see how to read a stack trace for what each part contains).
- Small, generic snippets that reveal nothing about your system: a regex, a sorting function, a SQL query with table names changed.
How to paste code more safely
- Strip secrets first. Replace them with placeholders like
API_KEY = "<redacted>". Search the snippet forkey,token,secret,passwordand://before sending. - Reduce it. Paste the smallest piece that reproduces the problem. A 20-line minimal example exposes far less than a 2,000-line file, and it is easier to reason about.
- Rename identifying details. Internal hostnames, product names, table names and customer names add nothing to most coding questions.
- Check your settings. On consumer plans, find the training or model-improvement setting and decide deliberately. Claude's Incognito chats and Gemini with Keep Activity off are the stricter options on those products.
- Use the right account. For work code, use the business plan or API key your company provides, not a personal account.
What about AI coding assistants in the editor?
Editor assistants and agents send more than you paste: they read open files, nearby files, and sometimes run commands. The same rules apply with higher stakes, because a .env file in your project folder can end up in the context without you choosing it. Keep secrets out of the working tree, use the tool's file-exclusion settings, and run it under your company's business plan. How to use AI for coding covers a workflow that keeps you in control of what the model sees.
The fully private option: run a model locally
If code must not leave your machine at all, run an open-weight model on your own hardware. Nothing is sent to a vendor, so training and retention questions disappear. The trade-off is quality and hardware: local models that fit on a laptop are less capable than the largest hosted ones. See how to run an LLM locally with Ollama to set one up.
Frequently asked questions
- Does ChatGPT train on code I paste?
- It depends on the plan and your settings. OpenAI's API documentation says data sent to the API is not used for training unless you opt in. For the consumer ChatGPT app, the training setting is in your account settings; read OpenAI's current help article on how your data is used, because the default differs between consumer and business plans and changes over time.
- Is it safe to paste code if I turn off training?
- Safer, not risk-free. Turning off training stops your chats being used to improve models, but vendors still store conversations for a period, may review flagged content for abuse, and keep feedback you submit. Secrets and confidential data should stay out regardless of the setting.
- Can my employer see what I paste into ChatGPT?
- If the account belongs to your company's workspace, assume its administrators can access or export what you write there, and that a company device may log your browser traffic. Chats in a personal account aren't visible to your employer through the vendor, but pasting company code into a personal account may break your employment contract or security policy.
- What is the safest way to get AI help on proprietary code?
- Use a business plan or API your company has approved, since the commercial terms we checked (Anthropic's commercial products and the OpenAI API) exclude training by default. For code that must never leave your machine, run an open-weight model locally, for example with Ollama, and accept that local models are usually less capable than the largest hosted ones.