10 min read · March 27, 2026
Every B2B SaaS product eventually gets the same request: "Can we add a custom field for X?" It starts with one customer asking for an Industry dropdown. Then another wants a Contract Value number field. Then an enterprise prospect won't sign unless they can customize your data model.
Building custom fields seems straightforward until you start. This guide covers every approach, the tradeoffs of each, and how to decide whether to build or buy.
Custom fields touch every layer of your stack:
Let's look at each database approach.
The most common modern approach. Add a custom_fields JSONB column to your existing tables.
ALTER TABLE contacts ADD COLUMN custom_fields JSONB DEFAULT '{}';
-- Store values
UPDATE contacts
SET custom_fields = '{"industry": "Healthcare", "contract_value": 50000}'
WHERE id = 'contact-123';
-- Query
SELECT * FROM contacts
WHERE custom_fields->>'industry' = 'Healthcare';Pros:
Cons:
The classic pattern. Three tables: entities, attributes (field definitions), and values.
CREATE TABLE field_definitions (
id UUID PRIMARY KEY,
tenant_id TEXT NOT NULL,
entity_type TEXT NOT NULL,
field_key TEXT NOT NULL,
field_label TEXT NOT NULL,
field_type TEXT NOT NULL,
validation JSONB
);
CREATE TABLE field_values (
id UUID PRIMARY KEY,
field_definition_id UUID REFERENCES field_definitions(id),
entity_id TEXT NOT NULL,
value TEXT NOT NULL
);Pros:
Cons:
A hybrid approach. Each tenant gets dedicated columns in a shared extension table.
CREATE TABLE contact_extensions (
contact_id UUID PRIMARY KEY REFERENCES contacts(id),
tenant_id TEXT NOT NULL,
field_1 TEXT,
field_2 TEXT,
field_3 NUMERIC,
-- ... up to N fields
);Pros:
Cons:
Salesforce uses a metadata-driven architecture with ~500 generic "flex columns" (Value0 through Value500). All stored as VARCHAR. A Universal Data Dictionary maps logical field names to physical column slots at runtime.
This is the gold standard but requires building an entire metadata layer, query translation engine, and caching system. Salesforce had hundreds of engineers working on this for years.
Source: Cirra - Salesforce Database Architecture
Building custom fields in-house typically takes 3-6 months of engineering time. The total cost is 3-4x the original estimate once you include development, maintenance (15-20% of build cost annually), security, and training.
Source: Appinventiv - Build vs Buy
For teams under ~100 engineers, the math rarely favors building infrastructure tools. 71% of tech teams choose off-the-shelf solutions to accelerate time-to-value.
Source: Chameleon - Build vs Buy
Build if:
Buy if:
Instead of building this infrastructure, you can use an API that handles it for you. Kopra provides:
npm install @kopra-dev/sdk, 5 lines to embedYour customers get the custom fields they've been asking for. Your engineering team stays focused on your core product.
import { KopraSDK } from '@kopra-dev/sdk';
const sdk = new KopraSDK({
currentTenant: 'northstar-staffing',
getToken: async (req) => {
const res = await fetch('/api/kopra-token', {
method: 'POST',
body: JSON.stringify(req),
});
return res.json();
},
});
await sdk.loadCustomFields('fields', {
fieldGroupKey: 'customer',
entityId: 'contact-42',
});Free tier available at kopra.dev. No credit card required.