How Text Watermarking Works
Learn how LLM text watermarking biases "green" tokens for statistical detection, what breaks it (paraphrasing, short text), and how to implement SynthID Text or Barium.

This is a technical post on textual watermarking. If you're new to watermarking in general, the Watermarking Rule Explained post covers when you're in or out; this one is the how for text.
In this post:
TLDR: the model secretly favours "green" tokens and avoids "red" tokens; a detector that knows the preferences, counts them and flags text where green shows up more often than chance.
Length is the limit: detectable from as few as 25 tokens (high-entropy text); short text = no signal.
What survives / what dies: copy-paste survives; paraphrase and translation kill it.
LLM providers already ship watermarks: Google uses SynthID Text (open-sourced), Anthropic watermarks all Claude text globally, OpenAI's textGrain targets EU outputs, and xAI's Grok API opt-in uses SynthID too.
If you're a builder: embed SynthID Text at generation time and run its detector in your middleware, or implement the Kirchenbauer method for a dependency-free z-test detector.
Introduction
You're tasked with wiring in an automated financial report generator. All the data is private, but based in the EU. The Product Owner has told you that the product needs to include watermarking in order to be compliant with the EU AI Act. You ask them how, they shrug and point to the legislation, which says "make reasonable efforts". How do you build something with those vague specifications?
You know the data can't leave the perimeter so you can't outsource to a watermarking API, the LLM is a fine-tuned open-weight model, and Article 50(2) makes you the provider. So, in this blog we will cover: how current watermarking works, what survives and what dies, how the current providers do it, and how to ultimately wire watermarking into your own stack.
The mechanism: Green tokens and a statistical test
Why not just add metadata? Usually the simplest way of marking text is to add metadata to the file (e.g. C2PA metadata to indicate AI generation). However, this is trivially easy to bypass: you can simply copy-paste the text into a new file, or go in and edit the metadata, while embedding the watermark directly into the text makes it much harder to remove. Embedded watermarks have been used to enable the detection of copyright infringements, academic fraud, and other malicious uses of AI-generated text.
How do you embed a watermark into text? Text watermarking works by biasing the model's word choices toward a secret "green list" of tokens; detection is a statistical test that counts green tokens and computes a z-score. But its roots are far older: textual fingerprinting, where signals are hidden in word choices so the source can be identified later. Intelligence agencies ran a per-copy version known as the barium meal test or canary trap (coined by Tom Clancy in his novel Patriot Games) to trace leaks. Here, synonyms were shuffled uniquely into every copy of a document, meaning that when news leaked to the press, agencies could identify the source by the exact words used. Academic versions followed for document provenance and copyright protection. And by 2017 neural network approaches using LSTMs and small language models were used for covert messaging (Fang et al. 2017, Ziegler et al. 2019). What changed with LLMs was the scale: as machine-generated text began to flood the web, identifying the source became a serious detection problem. Kirchenbauer et al. proposed the first practical LLM watermark at ICML in 2023, and Google's SynthID Text was the production implementation that followed in Nature in 2024, which is now open source.
Thanks to the EU AI Act, frontier labs have now joined: Anthropic explained Claude's watermark in August 2026, a version of the SynthID-Text technique which they applied globally; OpenAI's textGrain watermark, announced on 5 October 2026, is rolling out to ChatGPT and Codex text for EU users; and even xAI has SynthID Text as an opt-in for the Grok API.
But how does text watermarking actually work with LLMs? Kirchenbauer adapted the earlier fingerprinting techniques to consistently hide a single fingerprint inside all of a model's outputs. At generation time, a hash of the previous token seeds a pseudo-random split of the vocabulary into a "green list" and a "red list", and a logits processor adds a small bias to the green-list tokens before the model samples. No weights are touched: the bias is applied to the logits the final layer produces, not to the model itself. The result is that the output becomes more prone to select green-list tokens over others. This is similar to a biased coin: if you weight the coin heavily the fingerprint becomes rather obvious, but if you make the bias weaker it still may be detectable, just only statistically and not to the human eye.
Once we have generated the watermark, the next step is to detect it. To do this we need to know what the green/red list is. This list is created by a seeded hash of the previous token, meaning that anyone who has the hash function can re-derive the green list for any position and then count the frequency of "green list" tokens. No LLM is loaded, LLM weights are unaffected; the detector just counts and assesses whether the frequency of green tokens is significantly higher than the null expectation. This is done by calculating the z-score: the null hypothesis is rejected when z > 4, where the p-value is ~0.00003. This satisfies the EU AI Act's machine-readable requirement, but you'll still need to disclose in a human-readable manner too. This low-cost technique is also a sustainable answer to California's SB 942, where covered providers (GenAI systems with over 1 million monthly users, publicly accessible in California) must offer a free, publicly accessible AI detection tool via an API (though the tool mandate covers image, video and audio; text sits in SB 942's latent-disclosure duty). However, while publicly accessible detectors are great for transparency, the risk is that attackers can infer the green lists by querying a watermarked model repeatedly (~1 million queries — Sadasivan et al. queried a self-hosted OPT-1.3B; the "under $50" figure is ETH Zurich's separate attack on a production API) and so spoof your system outputs (essentially forging your watermark).
Kirchenbauer's technique is a reasonable trade-off: it creates a subtle bias towards a secret list of tokens at generation, then assesses the distribution of these tokens at detection. It doesn't drastically affect outputs, runs at low compute levels, and is robust enough to discourage the majority of users from removing the watermark (removal requires modifying roughly a quarter of the tokens). The technique is adaptable: to be more secure, you adjust the bias of the green list and regularly rotate hash keys. No system is perfect, though, and text-embedded watermarks do have vulnerabilities. The result is an arms race between the embedders and the strippers, and the next two sections will cover where the current weaknesses are and how people can strip watermarks.
The weaknesses: Output length and entropy
As with any method that relies on statistical tests, the biggest weakness is the "lack of n", the number of samples. In this case, that corresponds to the number of tokens in the output. Text watermarks need roughly 25 tokens of high-entropy text to detect reliably; short answers contain very little or no detectable watermark. This is the same problem as detecting a biassed coin: it would be impossible to tell whether a coin is biassed from a single flip, but by the eighth consecutive heads you're fairly certain. According to the Kirchenbauer paper, the hard variant (strong bias) detects any watermarked sequence with 16 or more tokens with certainty, while the soft variant crosses the z=4 detection threshold at roughly 30 tokens, and at 200 tokens 98.4% of AI-generated text is detected.
Length isn't the only variable that affects watermarking ability. Entropy is the other key axis: low-entropy text is text that can't be altered without significantly changing its meaning (e.g. factual answers, names, dates, code). Low-entropy text can't be watermarked because the model has no freedom to favour green tokens. textGrain turns this observation into a dial: its entropy budget only lets the watermark spend a fraction (β) of the model's next-token entropy, so confident, low-entropy outputs buy almost no signal by construction. The Kirchenbauer paper's own low-entropy example is code, for(i= 0;i<n;i++) sum+=array[i], where the first few tokens strongly determine the following tokens: humans and LLMs will give pretty much the same answer, so there's no statistical gap to detect. If you do force green tokens into it, the quality degrades to the point the code stops working. The figure above assumes high-entropy text; low-entropy text sits lower and crosses the threshold later, if at all. And Appendix G of the paper suggests factual Q&A is the hardest to watermark effectively: low-entropy answers yield weak detection statistics, though quality holds, with Exact Match dropping by less than 4 points for FLAN-UL2 and BLOOMZ on TriviaQA, because the soft watermark passively leaves high-confidence predictions (named entities, factual answers) untouched. Code is the extreme case of this — and a compliance question on top: Article 50(2) names audio, image, video and text, and says nothing about code, so whether the marking requirement even applies is unresolved (see the compliance guide).
What does this mean for when we build? If we're building some product that produces short or very deterministic outputs, then watermarking is not a feasible solution. This could be a chatbot for one-liners, or even an AI system using the recently released Jev. If compliance with Article 50(2) of the EU AI Act is still a requirement, then there are other methods alongside C2PA metadata that would probably count as "reasonable efforts" (and I'm not a lawyer, so don't take this as legal advice). The easiest would be inserting invisible unicode characters, though a single regex strips them and screenshots destroy them. More complex techniques such as Adversarial Watermarking Transformers (AWT) remain at the research stage and aren't production ready. And with respect to Jev: it is a discriminative model that returns probability distributions over choices (text or numbers), so arguably text watermarking doesn't apply to it at all (see System One docs).
Breaking the watermark: Which attacks actually work?
So what if our text is sufficiently long to carry a detectable watermark? What techniques work against the Kirchenbauer, SynthID and textGrain methods? The tldr is: copy-paste retains the watermark, but paraphrasing and translating the text defeats it.
Copy-paste and screenshots: The watermark survives
The Kirchenbauer method survives anything that leaves the words/tokens alone, because the mark lives in the word choices themselves. Copy-pasting an entire document is the obvious case, as is screenshotting. The method is stronger than that. Detection works from any contiguous portion of the text, so even quoting a single paragraph is enough, as long as it's roughly 25 tokens or more of high-entropy prose. The only way to remove the watermark is to change the words themselves.
Paraphrasing: Effective, if you rewrite enough
What techniques can actually defeat the watermark? Sadasivan et al. tried several attacks that can be best described as paraphrases. Given that the attacker is unlikely to know which tokens are green, the simplest attack is to try and rewrite the outputs, essentially paraphrasing them. This can be done using smaller LLMs that can be run locally (i.e. they won't have their own watermark). This works really well: Sadasivan et al. reported a drop in detection from 99.3% to 9.7% on 300-token passages, and two rounds of paraphrasing are enough to push detection below 50%. Content preservation and grammar accuracy stay high too (77% and 89% of paraphrases rated high quality respectively). However, if the paraphrase misses a few sentences that are partially or not at all paraphrased, the detector will still identify those sections, a point Kirchenbauer et al. themselves make. OpenAI's own textGrain evaluation shows the same curve on a production system: swapping 10% of words for synonyms cut detection from about 92% to 66% at a 1% false-positive rate, and 25% swaps pushed it down to 17%.
Translation attacks work (but there are quality risks)
The biggest gap with paraphrasing is that not all of the text gets changed, meaning you run the risk of letting a significant number of the green tokens through. What's needed is a way to change *all* the tokens without changing the meaning. The best way to do this is to translate the text, and then optionally translate it back. He et al. 2024 showed that current watermarks aren't consistent across languages and that with their carefully built pipeline they were able to remove the watermark without performance loss, dropping detection to random-guessing levels. One caveat, the attack needs an unwatermarked translator. Anthropic noted that watermarking is applied in all languages, so round-tripping through the same watermarked provider keeps the mark in place. But unless you want to operate in that second language, you'll have to translate it back to the original language. This means that your outputs are going through another round where the meanings could be altered.
There is a real cost here for both paraphrasing and translation. For most people, the choice is between spending more tokens for the same output (each round costs) or running a smaller model locally, which risks being less accurate, particularly if you have a large piece of text and the context window fills.
Shortening works best
The final attack is to shorten the text. And there are three ways to do this.
Simply cut off everything after 25 tokens.
Just keep 2-3 sentences verbatim.
Ask the LLM to "shorten this to 25 words or fewer". This is a hybrid of paraphrasing and shortening, and it's the most effective: re-rolling every token means the signal is never in the new text, while the compression removes the leftover spans a sloppy paraphrase would leave behind.
If the shortening takes the text below roughly 25 tokens of high-entropy prose, the watermark becomes hard to detect reliably. If the text is high-entropy, it may still be detectable, and in a short length of text there is only a certain amount of information you can convey. At some point, *the juice isn't worth the squeeze*. That's the test every attack in this section shares: how much of the token stream survives.
Implementation: SynthID text or textGrain?
Currently, there are two routes that are relatively easy to implement: self-hosting with SynthID Text, or using a provider's built-in watermarker. The choice depends on your detector requirements. If you're only watermarking and not detecting, the simplest choice is to use the provider's watermarker via API. However, their detectors are usually under the control of the provider and you might not be able to access them. For full control, SynthID Text is the recommendation: it's open-source, applied at generation time, with the detector trained and run by you. We'll start with SynthID.
How do you implement text-embedded watermarks? The open-source production implementation is Google's SynthID Text, which is applied at generation time as a logits processor (you need logits access to the model either through self-hosted weights or an API that exposes logit biasing). The Act is more specific than the Product Owner's shrug suggested: it asks for solutions that are "effective, interoperable, robust and reliable as far as this is technically feasible" (Art. 50(2)). This is the easy part. DeepMind and Hugging Face provide a guide, and the integration is included in the `transformers` library (v4.46.0 onwards); see the example below:
Two parameters are required. keys is a list of random integers; each one seeds a g-function, a scoring function that gives every token in the vocabulary a pseudo-random score based on the previous ngram_len tokens. 20 to 30 unique numbers is the recommended range, balancing detectability against generation quality. ngram_len controls the robustness/detectability trade-off: the larger the value, the more detectable the watermark, at the cost of being more brittle to changes (five is a good default, and it needs to be at least 2).
Two things differ from Kirchenbauer's scheme. Where Kirchenbauer uses one hash-seeded green/red split, SynthID Text scores every token through multiple g-functions (one per key) and favours the high scorers through tournament sampling, where tokens compete in knockout pairings and the higher-scoring token wins each round. And detection runs through a trained classifier rather than a token count: every configuration needs its own detector trained on watermarked and non-watermarked outputs (a minimum of 10,000 examples is recommended). The library ships the detector architecture and an end-to-end training example, but the training run is on you (the snippet above is for embedding only). Both the integration and DeepMind's reference implementation are Apache 2.0, so there are no issues with licensing.
Installation is one line: pip install "transformers[torch]" (the [torch] extra pulls in PyTorch, which the watermarking classes require; plain pip install transformers works, but the config classes will raise an ImportError without it). The library needs Python 3.10+ and PyTorch 2.6+.
The code above works because you can control the sampling loop (specifically the logits). If you call a closed API you don't control the loop and so you will have to rely on the provider to implement watermarking. And they should be doing it, but the risk is you may have no way to verify the watermark is present (xAI's `x-watermark` header states that it is watermarked, but it is metadata only; to actually verify the mark, a detector is still needed). And if you route through an aggregator such as OpenRouter, you get open-weight models without the control that self-hosting gives you, and you still don't have the key to check the watermark (SB 942's detector mandate doesn't cover text, see above). This is a key strength of self-hosting: you can apply SynthID Text yourself at generation time. The trade-off is the one covered above: the detector is a trained classifier, and the training run is on you.
Whichever route you take, the compute cost is modest, as covered below. The three frontier labs each ship a built-in text watermark, and the differences are easiest to see side by side:
OpenAI's textGrain is the provider-side counterpart to SynthID. It works at decoding time where a secret key and a window of preceding tokens produce pseudorandom values. The vocabulary is split into keyed blocks, and an optimal transport solve nudges the block distribution under an entropy budget. This is averaged over keys, so the output distribution is unchanged, which is how OpenAI claims there is no quality hit. Detection needs only the text and the key, but only OpenAI and select researchers can currently run it. This means you cannot check yourself, until OpenAI open-sources the technology (OpenAI says it plans to, but hasn't specified a date).
Anthropic's explainer landed in August 2026. Claude's watermark is a version of SynthID-Text, where tokens compete in knockout pairings and the higher-scoring token wins each round. It's applied globally as Anthropic can't yet scope it by region. Nothing is added to the text: the watermark only changes the source of randomness used to pick among plausible words, so Anthropic reports no quality impact and no price or speed change. One caveat if you build on Claude: on some earlier models, the watermark may not reliably carry when you set `temperature`, `top_p` or `top_k` to non-default values.
xAI's Grok API is the most recent addition. The docs state the implementation uses SynthID Text, across seven Grok models and both the Responses and Chat Completions APIs. It also covers structured outputs and tool-call arguments. However, watermarking is off by default: only team admins switch it on per model, and turning a model off means confirming that a legal exception applies. Every response carries an `x-watermark` header, so you can log which outputs were marked. But as noted above, that's metadata only, and xAI hasn't published any detection accuracy figures.
The compute cost
There are two aspects to consider when calculating the cost of watermarking. First, what does embedding cost? And secondly, what does detection cost? The embedding itself is relatively cheap: it is basically applying a per-token bias on top of the model's forward pass, making it negligible relative to the inference itself. Detection depends on the method. SynthID's classifier is a trained model, so it is practically limited to GPU-based inference (but still less compute than generation), while the classic Kirchenbauer method is a z-test, which boils down to counting "green tokens" (i.e. trivial CPU usage). The real costs lie in the operational aspects. You'll need to consider key management (e.g. how many different keys will you support: more keys makes it harder to reverse engineer via the detector, but a higher chance of a false positive), detector availability (open to the public, automated checking, internal use only), logging (which texts were watermarked and with which key). These decisions will also need to factor in the security aspects that are discussed in the next paragraph.
Security: everything hinges on the key
The first of those security aspects is key management. The Kirchenbauer method is designed to be public: anyone with the hash function (key) can re-derive the green lists and verify a watermark, which is what makes third-party detection possible. However, the same public key lets an attacker spoof your outputs (i.e. write human text that flags as AI-generated). Basically, if someone is able to work out your key(s) then they will know the green lists and then know how to write in your style. This would be similar to someone mimicking Claude by using em-dashes, 'not X but Y' constructions, and heavy emoji use. This may seem pointless, but the threat is that certain texts could be falsely attributed to you or your company, which could have legal consequences. Therefore it's important to try and protect your keys. Sadasivan et al. demonstrated this by querying a watermarked model one million times to infer the green lists, and then were able to spoof the detector. Knowing the green lists also makes evasion even easier. Instead of having to run a paraphrase attack on the whole text and risk losing text quality, they can simply paraphrase away from the green tokens. There are ways to protect this: the more keys you use, the harder it becomes to brute force (using 5 keys that rotate within the text at random token lengths makes it near impossible for all but the most determined attackers). This rotation can also reduce the danger of false positive watermark detection. SynthID is different: its detector is a trained classifier that outputs a probability, and it is specific to your text outputs. It is still vulnerable to brute-force methods where continually querying the detector can help you infer what the watermark is (see Omidi et al. 2026a and Omidi et al. 2026b). These brute-force attacks typically need over one million queries to be successful, so the safest defence is to allow queries via a rate-limited API and guard which keys you are using.
The self-hosted PII scenario
Coming back to the original problem that our Product Owner gave us. Only deploying locally probably doesn't exempt you: the EU AI Act defines it as putting it into service, which covers internal deployment. Additionally, even if use of the system is not governed transactionally, you may still be in scope. The only exceptions to watermarking are R&D (Art 2(8)) and purely personal use (Art 2(10)). Watermarking also has uses aside from legal compliance. Adding a watermark will allow you to determine where the leak came from, similar to the Barium/Canary trap technique I talked about earlier. Therefore, your options are either to use SynthID Text or to build your own middleware to embed a watermark alongside adding C2PA metadata. However, if the output genuinely never leaves the perimeter and is never disclosed, the case for watermarking is weak; but the moment it does via a report, email, or a client deliverable, you're arguably a provider under the EU AI Act.
Bottom line for builders
As a general rule of thumb, I'd suggest applying a watermark, as it represents current best practice, safeguards you against future changes in either product use or legislation, and provides you with experience that can be applied to other projects. The easiest thing to do is embed with SynthID Text at generation time and run its detector in your validation middleware, or implement the Kirchenbauer method discussed above, whose detector is a dependency-free z-test. If you build on OpenAI's API instead, textGrain is an opt-in flag (and already the default for EU ChatGPT and Codex text), but with no public detector you're trusting the provider that the mark is present. On Anthropic's API, Claude text is watermarked by default worldwide, and a private-preview detection API exists for organisations that must verify marks for their own compliance. xAI's Grok API is the same SynthID Text under the hood, off by default with an admin opt-in, and its responses carry an `x-watermark` header you can log. Additionally, purely relying on C2PA metadata could land you in serious trouble as that can be easily removed and does not reflect current best practice.
Be aware of the limits, though. Text watermarks need roughly 25 tokens of high-entropy text to detect reliably, so short answers carry no signal. Paraphrasing and translation defeat them entirely, and code is currently a blindspot: the Act arguably applies, but no technique can satisfy it. Honestly, watermarking is not unbreakable: it raises the cost of evasion, it doesn't make it impossible. However, even though stripping the watermark is not illegal, it likely breaks the ToS, and to do it directly requires you to have access to the logits, which most frontier model providers do not make available. For most work it is just not worth the effort. For your own outputs, though, watermarking is the difference between claiming compliance and being able to demonstrate it.
Cross-links: Watermarking Rule Explained (the "what" companion), main compliance guide.
