Toolbox-XToolbox-X

Extract Object Keys

Extracts the keys of an object with proper typing at the top-level or recursively.

extractObjectKeys

The extractObjectKeys function extracts the keys of an object with proper typing.

Function Signatures

function extractObjectKeys<T extends GenericObject>(obj: T): Array<keyof T>
function extractObjectKeys<T extends GenericObject>(obj: T, tuple: true): Tuple<keyof T>

Parameters

  • obj (T): The object to extract keys from.
  • tuple (boolean, optional): If true, returns keys as a tuple instead of an array.

Return Value

  • Array<keyof T> | Tuple<keyof T>: The keys of the object. Returns an empty array if the input is null or undefined.

Example Usage

playground.ts

Aliases

The following aliases can be used for the extractObjectKeys function:

  • extractKeys

extractObjectKeysDeep

Recursively extracts all nested keys from an object with proper typing.

Function Signature

function extractObjectKeysDeep<T extends GenericObject>(obj: T): Array<DeepKeys<T>>

Parameters

  • obj (T): The object to extract keys from.

Return Value

  • Array<DeepKeys<T>>: An array of all nested keys. Returns an empty array if the input is null or undefined.

Example Usage

playground.ts

Aliases

The following aliases can be used for the extractObjectKeysDeep function:

  • extractKeysDeep

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page