datafog core
Find and transform sensitive data in your application.
Quickstart ·
Detection ·
Transformations ·
Local models ·
Documentation
datafog core is a Rust library with Python, Node.js, and browser WebAssembly bindings. Scan text or JSON for personal data and credentials, then redact, mask, remove, pseudonymize, or tokenize matched values. Findings use a consistent format across the bindings.
Rule-based scanning runs locally without model weights or downloads. Optional local model sessions add datafog and GLiNER2 support in Rust, Python, and Node.js.
Release: coordinated Core 1.8.0 for Python, Rust, Node.js, WASM and the Core-owned companion packages · 1.8 release notes · Python release history · 1.5 migration guide · Earlier cross-SDK 1.1.0 notes · Extension installation and testing.
Core 1.8.0 fixes EMAIL matching in text written without spaces (#272): alice@example.comとbob@example.net now finds both addresses, and SSNは123-45-6789でメールはalice@example.comです reports the SSN and address separately. It retains the EMAIL and PHONE fixes from 1.7. Consumers need to admit 1.8.0 in their version constraints to receive the new fix.
Core 1.0 freezes Workspace contract 1 across Rust, Python, Node and browser WASM, with optional native/browser FogVault integrations. Snapshot v3 writes and v1/v2/v3 reads keep their existing semantics. Exact published 0.5.0-beta.3 interchange remains tested; FogVault is independently versioned 0.1.0.
Quickstart
The coordinated Core release is 1.8.0 across PyPI, crates.io and npm. Applications should lock the exact version they have qualified. The datafog Python application and FogVault version independently of Core.
| SDK |
Published install |
Requirements |
| Python |
python -m pip install datafog-core==1.8.0 |
Python 3.10+ |
| Node.js |
npm install --save-exact @datafog/node@1.8.0 |
Node.js 24+ |
| Rust |
cargo add datafog-core@=1.8.0 |
Rust 1.88+ |
| Browser / WASM |
npm install --save-exact @datafog/wasm@1.8.0 |
Browser with WebAssembly support |
Python
from datafog_core import scan, scan_and_transform
findings = scan("Email jane@example.com")
print(findings[0].entity_type) # EMAIL
print(findings[0].matched_text) # jane@example.com
result = scan_and_transform(
"Email jane@example.com",
{"transform": {"default": {"strategy": "redact"}}},
)
print(result.text) # Email [EMAIL]
Node.js example
import { scan, scanAndTransform } from "@datafog/node";
const findings = scan("Email jane@example.com");
console.log(findings[0].entityType); // EMAIL
console.log(findings[0].matchedText); // jane@example.com
const result = scanAndTransform("Email jane@example.com", {
transform: { default: { strategy: "redact" } },
});
console.log(result.text); // Email [EMAIL]
Rust example
use datafog_core::{
scan, scan_and_transform, PrivacyError, ScanAndTransformConfig,
TransformationConfig, TransformationStrategy,
};
fn main() -> Result<(), PrivacyError> {
let findings = scan("Email jane@example.com");
println!("{}", findings[0].entity_type); // EMAIL
println!("{}", findings[0].matched_text); // jane@example.com
let result = scan_and_transform(
"Email jane@example.com",
&ScanAndTransformConfig::new(TransformationConfig::new(
TransformationStrategy::Redact,
)),
)?;
println!("{}", result.text); // Email [EMAIL]
Ok(())
}
Browser / WASM example
import { init, scan, scanAndTransform } from "@datafog/wasm";
await init();
console.log(scan("Email jane@example.com"));
const result = scanAndTransform("Email jane@example.com", {
transform: { default: { strategy: "redact" } },
});
console.log(result.text); // Email [EMAIL]
The Python 1.8.0 package ships CPython 3.10+ ABI3 wheels for Linux x64 and
ARM64 (manylinux_2_28 and musllinux_1_2), Linux s390x and ppc64le
(manylinux_2_28), macOS Apple Silicon 11+, and Windows x64/ARM64. The
Node.js 1.8.0 package ships Linux x64/ARM64 GNU, macOS Apple Silicon, and
Windows x64 binaries.
After 1.6.0, release CI no longer builds or qualifies Intel macOS: future
Python releases omit its wheel and future Node releases omit darwin-x64.
Existing 1.6.0 archives remain available. Intel source builds are outside the
maintained CI matrix.
PyPy, free-threaded CPython, older glibc/musl and other architectures fall back
to a source build. That route requires Rust 1.88+, Cargo, a native linker and
access to the Rust build dependencies; installation can take several minutes.
To require a prebuilt wheel, use python -m pip install --only-binary=:all: datafog-core. See installation requirements.
Detection coverage
| Coverage |
Entity types |
Activation |
| Personal and financial data |
EMAIL, PHONE, SSN, CREDIT_CARD, IP_ADDRESS, DATE, ZIP_CODE |
On by default |
| Credentials |
API_KEY, BEARER_TOKEN, JWT, PRIVATE_KEY, CREDENTIAL_URI |
On by default |
| Labeled street addresses |
STREET_ADDRESS |
On by default; bounded English street-line rule |
| Labeled accounts |
ACCOUNT_NUMBER |
On by default; bounded lexical rule |
| Labeled US identifiers |
US_ROUTING_NUMBER, NPI |
On by default; requires a supported text label |
| German identifiers |
IBAN, VAT ID, tax ID, social security number, postal code, passport number, residence permit number |
Explicit German locale |
| UUIDs |
UUID |
Explicit detect_uuid setting |
| Names in JSON fields |
PERSON |
Structured scans, using name-field aliases or explicit JSON Pointer mappings |
| Names and address blocks in prose |
PERSON, ADDRESS |
EmbeddedCnnDetector: weights compiled into the extension, no download or runtime |
| Caller-defined labels |
any |
GLiNER2 model sessions |
Use structured scans to find names by JSON field, EmbeddedCnnDetector for recipient names and mailing-address blocks in prose, or model sessions for caller-defined labels.
Each finding includes its entity type, matched text, byte and code-point ranges, optional confidence, and detector name/version. Ranges are zero-based and end-exclusive. Node.js and WASM also provide UTF-16 ranges for JavaScript slice. Rule-based findings have no confidence score. Findings and ranges →
For scanning files from AI agents, use datafog MCP.
Detection settings
- Select checks:
scan(text, {"entities": ["EMAIL", "SSN"]}) in Python runs only the selected text detectors. Omit entities to use all enabled detectors. Selections must be nonempty, unique, exact entity names. Selecting a German type or UUID does not activate it; set locale or detect_uuid too.
- Literal denylists:
{"deny": [{"phrase": "Project Atlas"}]} adds explicit sensitive phrases. Rules default to case-sensitive whole-phrase word boundaries; substring and Unicode case-insensitive options are available. Explicit deny matches win allowlists. Matching and policy rules →
- German locale:
{"locale": "de"} enables the seven German detectors. These use format/context rules; IBAN checksums and account existence are not verified. See the German reference for detector rules.
- ENV and SQL: choose
format: "env" or format: "sql" to handle email boundaries in assignments and quoted strings. Source-context rules →
- Phone numbers: numbers without
+ use North American checks: ten digits, optionally preceded by 1, with area codes starting with 2–9 and exchange codes starting with 1–9. Numbers starting with + use a permissive 7–15 digit check, including shortened examples such as +1-555-1002. Country codes and assigned numbers are not validated; numeric identifiers can still match.
- Decimal numbers and CSV: contiguous card digits after a digit and
. or , are suppressed, so 3.4111111111111111 and 3,4111111111111111 do not produce card findings. Cards containing spaces or hyphens still undergo normal checks. Parse CSV/TSV into cells before scanning so delimiters and adjacent fields do not affect matching.
Use capabilities() in Rust or Python to discover supported entities and their activation rules.
Transformations
| Strategy |
Result |
Application provider |
Browser / WASM |
redact |
Replace with a label such as [EMAIL] |
None |
Supported |
mask |
Replace characters, optionally revealing the first or last characters |
None |
Supported |
remove |
Delete the matched span |
None |
Supported |