Provides an encryptedField function that wraps common Payload field types and encrypts their values before they are stored. It uses AES-256-CTR with the PAYLOAD_SECRET and a random IV, and hooks handle encryption and decryption automatically in the admin panel and the API. Encrypted fields cannot be sorted or filtered in the database.
Database field encryption for Payload.
Installation
npm i @oversightstudio/encrypted-fields83
Stars
9
Forks
2
Open Issues
Today
Last Updated
55
Weekly Downloads
v1.0.0
npm Version
9.9 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Shared by 3 plugins in oversightstudio/payload-plugins.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/932147916-encrypted-fields)<a href="https://payloaddirectory.dev/plugins/932147916-encrypted-fields"><img src="https://payloaddirectory.dev/badge/932147916-encrypted-fields.svg" alt="Payload Directory"></a>README
pnpm add @oversightstudio/encrypted-fields @payloadcms/ui
This package brings encrypted fields to Payload. It provides an encryptedField function that allows you to easily add encrypted fields to your collections.
It supports most field field types, including ones like select or number with hasMany enabled. Additionally, it fully integrates with Payload’s field customization options and lifecycle events, making it behave just like any other field—just encrypted.
The package automatically encrypts and decrypts field values using hooks, meaning you don’t need any extra setup to use encrypted fields in the admin panel or through the API.
This package uses AES-256-CTR encryption, combined with your PAYLOAD_SECRET and a random IV. The encrypted value is stored as a string in the database.
For a deeper dive into how this encryption works, check out this blog post by Payload. It explains the same encryption approach but for a simple text field. This package expands on that to support more field types and make integration seamless.
Since encryption fundamentally converts data into an unreadable format, this package JSON stringifies your data before encrypting it and automatically parses it back after decryption to retain it's original data type.
Using field encryption comes with some tradeoffs:
These tradeoffs are standard when working with encrypted data, but they’re well worth it if protecting sensitive information is your goal.
Important: Make sure the PAYLOAD_SECRET environment variable is set before using this package.
import { CollectionConfig } from 'payload'
import { encryptedField } from '@oversightstudio/encrypted-fields'
export const SensitiveDataCollection: CollectionConfig = {
slug: 'sensitive-data',
fields: [
encryptedField({
name: 'name',
type: 'text',
}),
encryptedField({
name: 'age',
type: 'number',
}),
encryptedField({
name: 'birthDate',
type: 'date',
}),
encryptedField({
name: 'traits',
type: 'select',
options: [
{ label: 'Awesome', value: 'awesome' },
{ label: 'Based', value: 'based' },
{ label: 'Goat', value: 'goat' },
],
hasMany: true,
}),
],
}
| Field Type | Supported |
|---|---|
text | ✅ Yes |
number | ✅ Yes |
select | ✅ Yes |
checkbox | ✅ Yes |
email | ✅ Yes |
date | ✅ Yes |
json | ✅ Yes |
textarea | ✅ Yes |
code | ✅ Yes |
radio | ✅ Yes |
point | ❌ Not yet supported |
richText | ❌ Not yet supported |
All other missing field types (like as ui, tabs, etc.) are of course not supported, as they do not store user data that needs encryption.
Topics
payload icon picker
Icon picker field with searchable dropdown or drawer grid that stores the icon name and raw SVG
690/wk52v3
payload phone number plugin
Phone number field with country selection, formatting and validation powered by libphonenumber-js
64114/wk16v3
payload plugin json form builder
Edit a Payload JSON field as real admin fields using a builder inside the admin panel
580/wk29v3
payload plugin icons
Icon picker field for Payload with Lucide and Phosphor providers and a React rendering component
570/wk2v3
select search field
Server-backed searchable select field for Payload with custom search functions
560/wk15v3
link field
Link field and Lexical link feature for internal and custom URLs with document URL resolution
550/wk0v4