---
title: "Create Environments with Masked Production Data Using Neon Branches"
description: "Neon combines copy-on-write database branches with the PostgreSQL Anonymizer (anon) extension to create production-like non-prod environments without exposing PII."
url: "https://swe.quest/articles/create-environments-with-masked-production-data-using-neon-branches-29a6a3b3a1320ce4"
canonical: "https://neon.com/blog/environments-masked-production-data"
source: "Neon"
published: "2025-05-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["postgres","privacy","testing","ci-cd"]
---

# Create Environments with Masked Production Data Using Neon Branches

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-05-15, 7 min read, How-to. Original: [https://neon.com/blog/environments-masked-production-data](https://neon.com/blog/environments-masked-production-data)

## Summary

Neon combines copy-on-write database branches with the PostgreSQL Anonymizer (anon) extension to create production-like non-prod environments without exposing PII. The workflow branches from production, applies column-level static masking rules via SECURITY LABEL declarations and faker functions (anon.fake, anon.partial, anon.noise), runs anon.anonymize\_database(), and then uses the anonymized branch as the base for per-PR previews, CI, local dev and contractor access. Masking preserves schema, types and referential integrity, and the anonymization step can be automated with a GitHub Action on pull request creation.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Privacy](https://swe.quest/tags/privacy.md) (Security)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Postgres extensions ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Neon, PostgreSQL Anonymizer, Neon branches, GitHub Actions, copy-on-write

## Related posts

- [Branching With or Without PII: The Future of Environments](https://swe.quest/articles/branching-with-or-without-pii-the-future-of-environments-9928f840495df503.md): Neon · 2025-11-11 · Easy · 12 min read · PostgreSQL, Privacy, Databases, CI/CD
  Neon branches can now be created with anonymized data: schema and data are copied from a parent such as production, then masked with the PostgreSQL Anonymizer extension using per-column rules (dummy emails, names, phone numbers, random values) while foreign keys and constraints stay intact.
- [How to Handle PII in Staging Databases Without Losing Realistic Data](https://swe.quest/articles/how-to-handle-pii-in-staging-databases-without-losing-realistic-data-41c0818c53e7c05e.md): Neon · 2025-11-17 · Medium · 11 min read · Privacy, PostgreSQL, Testing, Databases
  Four common ways to get realistic but PII-safe staging data are compared, with code for each: manual CSV export plus Python anonymization scripts, Faker-based masking libraries with deterministic seeding to preserve referential integrity, fully synthetic data generators, and replication into staging with SQL masking views or the PostgreSQL Anonymizer extension (declarative security labels, dynamic masking, anonymized dumps, k-anonymity checks).
- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests.
- [A database for every preview environment using Neon, GitHub Actions, and Vercel](https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5.md): Neon · 2023-04-14 · Medium · 14 min read · PostgreSQL, CI/CD, Deployment, Schema migrations
  Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases.
- [Practical Guide to Database Branching](https://swe.quest/articles/practical-guide-to-database-branching-8aa2f63325bcfecb.md): Neon · 2025-12-04 · Medium · 9 min read · PostgreSQL, Databases, CI/CD, Schema migrations, Testing
  Neon's copy-on-write storage makes Postgres database branches instant and cheap: each branch shares the parent's base data, gets its own autoscaling compute that scales to zero, and can be created from any point within the history retention window.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
