Skip to content

Built-in Presets/API

MaskIO provides predefined common masking rules and core API: maskText and maskObject.

API

APIDescriptionVersion
maskTextString masking processor
maskObjectObject/Array/Array-object masking processor

maskText Parameters

maskText: (text: string, config: MaskIoConfig, defaultConfig?: MaskIoConfig)

  • text: Required Input string to be masked
  • config: Required Masking configuration (presets or custom rules)
  • defaultConfig: Optional Fallback masking configuration (presets or custom rules)

maskObject Parameters

maskObject: (obj: Record<string, any> | any[], config: Record<string, MaskIoConfig | FieldHandler>)

  • obj: Required Object or array to be masked
  • config: Required Masking configuration mapping (keys as paths, values as configs or field handlers)

Preset Rules

Preset NameDescription
allAll mask Replaces the entire string with mask characters.
bankCardBank card Displays the last four digits of the card number, masks preceding digits.
idCardID card number Displays the first 3 digits and last 2-4 digits, with other parts replaced by mask characters.
userNameName Displays the last character of the name.
emailEmail Preserves the first two characters and domain suffix, masks other parts. Applies full masking if no match is found.
phonePhone number Applies region-specific masking patterns while preserving certain digits.
landlineLandline number Displays area code and last two digits by default, shows last two digits for other formats.
amountMonetary amount Full masking.
verificationVerification code Full masking.
addressAddress Full masking.
ipIP address Displays the first three segments, masks the last segment.
urlURL Preserves domain and path, masks query parameters.
licensePlateLicense plate Displays the first two characters, masks subsequent parts.