Skip to content

objectenvy

Merging

FunctionDescription
mergeRecursively merge two configuration objects, with obj2 winning on conflicts.
overrideApply default values to a config object, filling in only the keys that are absent in config.

Parsing

NameDescription
defaultNonNestingPrefixesPrefix segments that are never treated as nesting roots regardless of how many env vars share them.
coerceValueCoerce a raw environment variable string to its most appropriate JavaScript type.
objectEnvyCreate a memoized configuration loader with preset options, returning bound objectify and envy helpers.
objectifyParse process.env (or a custom env object) into a strongly-typed, nested, camelCased config object.
safeObjectifyNon-throwing variant of objectify. Returns a discriminated union instead of throwing on validation failure or transform errors.
toCamelCaseConvert a SCREAMING_SNAKE_CASE string to camelCase.

Serialization

FunctionDescription
envySerialize a nested camelCased config object back to a flat SCREAMING_SNAKE_CASE env record.
toSnakeCaseConvert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE.

Type Utilities

NameDescription
MergeOptionsOptions for controlling the merge behaviour of merge() and override().
ObjectEnvyOptionsConfiguration options for objectify() — controls prefix filtering, env source, Zod schema validation, camelCase nesting behaviour, and include/exclude patterns.
ArrayMergeStrategyStrategy for merging arrays when combining configuration objects via merge() or override().
ConfigObjectNested configuration object with string keys and recursively nested values. Exported as ConfigObject — represents a parsed environment config tree.
ConfigValueA single configuration value — either a primitive string/number/boolean, an array of primitives/objects, or a nested ConfigObject. Exported as ConfigValue.
FromEnvConvert a flat SCREAMING_SNAKE_CASE env record type to a nested camelCase config type.
SchemaToEnvExtract the flat SCREAMING_SNAKE_CASE env record type from a Zod schema or a plain config type.
ToEnvConvert a nested camelCase config type to a flat SCREAMING_SNAKE_CASE env record, preserving string literal and template literal types.
WithoutPrefixRemove a Prefix_ from all keys in an env record type, keeping only the matching keys.
WithPrefixAdd a Prefix_ to all keys in an env record type.

Released under the MIT License.