Skip to content

Finance

Module to generate finance and money related entries.

Overview

For a random amount, use amount().

For traditional bank accounts, use: accountNumber(), accountName(), bic(), iban(), pin() and routingNumber().

For credit card related methods, use: creditCardNumber(), creditCardCVV(), creditCardIssuer(), transactionDescription() and transactionType().

For blockchain related methods, use: bitcoinAddress(), ethereumAddress() and litecoinAddress().

account

Deprecated

This method is deprecated and will be removed in a future version.

Use faker.finance.accountNumber instead.

Generates a random account number.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
length?number8

The length of the account number.

Returns: string

ts
faker.finance.account(length?: number = 8): string
faker.finance.account() // 92842238
faker.finance.account(5) // 32564

accountName

Generates a random account name.

Available since v2.0.1

Returns: string

ts
faker.finance.accountName(): string
faker.finance.accountName() // 'Personal Loan Account'

accountNumber

Generates a random account number.

Available since v8.0.0

Parameters

NameTypeDefaultDescription
optionsOrLength?number | { ... }{}

An options object or the length of the account number.

optionsOrLength.length?number8

The length of the account number.

Returns: string

ts
faker.finance.accountNumber(optionsOrLength?: number | {
  length: number
} = {}): string
faker.finance.accountNumber() // 92842238
faker.finance.accountNumber(5) // 28736
faker.finance.accountNumber({ length: 5 }) // 32564

amount

Generates a random amount between the given bounds (inclusive).

Available since v2.0.1

Parameters

NameTypeDefaultDescription
options?number | { ... }{}

An options object.

options.autoFormat?booleanfalse

If true this method will use Number.toLocaleString(). Otherwise it will use Number.toFixed().

options.dec?number2

The number of decimal places for the amount.

options.max?number1000

The upper bound for the amount.

options.min?number0

The lower bound for the amount.

options.symbol?string''

The symbol used to prefix the amount.

legacyMax?number1000

The upper bound for the amount.

legacyDec?number2

The number of decimal places for the amount.

legacySymbol?string''

The symbol used to prefix the amount.

legacyAutoFormat?booleanfalse

If true this method will use Number.toLocaleString(). Otherwise it will use Number.toFixed().

Returns: string

ts
faker.finance.amount(options?: number | {
  autoFormat: boolean,
  dec: number,
  max: number,
  min: number,
  symbol: string
} = {}, legacyMax?: number = 1000, legacyDec?: number = 2, legacySymbol?: string = '', legacyAutoFormat?: boolean = false): string
faker.finance.amount() // '617.87'
faker.finance.amount({ min: 5, max: 10 }) // '5.53'
faker.finance.amount({ min: 5, max: 10, dec: 0 }) // '8'
faker.finance.amount({ min: 5, max: 10, dec: 2, symbol: '$' }) // '$5.85'
faker.finance.amount({ min: 5, max: 10, dec: 5, symbol: '', autoFormat: true }) // '9,75067'

bic

Generates a random SWIFT/BIC code based on the ISO-9362 format.

Available since v4.0.0

Parameters

NameTypeDefaultDescription
options{ ... }{}

Options object.

options.includeBranchCode?booleanfaker.datatype.boolean()

Whether to include a three-digit branch code at the end of the generated code.

Returns: string

ts
faker.finance.bic(options: {
  includeBranchCode: boolean
} = {}): string
faker.finance.bic() // 'WYAUPGX1'
faker.finance.bic({ includeBranchCode: true }) // 'KCAUPGR1432'
faker.finance.bic({ includeBranchCode: false }) // 'XDAFQGT7'

bitcoinAddress

Generates a random Bitcoin address.

Available since v3.1.0

Returns: string

ts
faker.finance.bitcoinAddress(): string
faker.finance.bitcoinAddress() // '3ySdvCkTLVy7gKD4j6JfSaf5d'

creditCardCVV

Generates a random credit card CVV.

Available since v5.0.0

Returns: string

ts
faker.finance.creditCardCVV(): string
faker.finance.creditCardCVV() // '506'

creditCardIssuer

Returns a random credit card issuer.

Available since v6.3.0

Returns: string

ts
faker.finance.creditCardIssuer(): string
faker.finance.creditCardIssuer() // 'discover'

creditCardNumber

Generates a random credit card number.

Available since v5.0.0

Parameters

NameTypeDefaultDescription
options?string | { ... }{}

An options object, the issuer or a custom format.

options.issuer?string''

The name of the issuer (case-insensitive) or the format used to generate one.

Returns: string

ts
faker.finance.creditCardNumber(options?: string | {
  issuer: string
} = {}): string
faker.finance.creditCardNumber() // '4427163488662'
faker.finance.creditCardNumber({ issuer: 'visa' }) // '4882664999007'
faker.finance.creditCardNumber({ issuer: '63[7-9]#-####-####-###L' }) // '6375-3265-4676-6646'
faker.finance.creditCardNumber('visa') // '1226423499765'

currency

Returns a random currency object, containing code, name and symbol properties.

Available since v8.0.0

Returns: Currency

ts
faker.finance.currency(): Currency
faker.finance.currency() // { code: 'USD', name: 'US Dollar', symbol: '$' }

currencyCode

Returns a random currency code. (The short text/abbreviation for the currency (e.g. US Dollar -> USD))

Available since v2.0.1

Returns: string

ts
faker.finance.currencyCode(): string
faker.finance.currencyCode() // 'USD'

currencyName

Returns a random currency name.

Available since v2.0.1

Returns: string

ts
faker.finance.currencyName(): string
faker.finance.currencyName() // 'US Dollar'

currencySymbol

Returns a random currency symbol.

Available since v2.0.1

Returns: string

ts
faker.finance.currencySymbol(): string
faker.finance.currencySymbol() // '$'

ethereumAddress

Creates a random, non-checksum Ethereum address.

To generate a checksummed Ethereum address (with specific per character casing), wrap this method in a custom method and use third-party libraries to transform the result.

Available since v5.0.0

Returns: string

ts
faker.finance.ethereumAddress(): string
faker.finance.ethereumAddress() // '0xf03dfeecbafc5147241cc4c4ca20b3c9dfd04c4a'

iban

Generates a random iban.

Available since v4.0.0

Parameters

NameTypeDefaultDescription
options?boolean | { ... }{}

An options object or whether the return value should be formatted.

options.countryCode?string

The country code from which you want to generate an IBAN, if none is provided a random country will be used.

options.formatted?booleanfalse

Return a formatted version of the generated IBAN.

legacyCountryCode?string

The country code from which you want to generate an IBAN, if none is provided a random country will be used.

Returns: string

Throws: Will throw an error if the passed country code is not supported.

ts
faker.finance.iban(options?: boolean | {
  countryCode: string,
  formatted: boolean
} = {}, legacyCountryCode?: string): string
faker.finance.iban() // 'TR736918640040966092800056'
faker.finance.iban({ formatted: true }) // 'FR20 8008 2330 8984 74S3 Z620 224'
faker.finance.iban({ formatted: true, countryCode: 'DE' }) // 'DE84 1022 7075 0900 1170 01'

litecoinAddress

Generates a random Litecoin address.

Available since v5.0.0

Returns: string

ts
faker.finance.litecoinAddress(): string
faker.finance.litecoinAddress() // 'MoQaSTGWBRXkWfyxKbNKuPrAWGELzcW'

mask

Deprecated

This method is deprecated and will be removed in a future version.

Use faker.finance.maskedNumber instead.

Generates a random masked number.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
length?number4

The length of the unmasked number.

parens?booleantrue

Whether to use surrounding parenthesis.

ellipsis?booleantrue

Whether to prefix the numbers with an ellipsis.

Returns: string

ts
faker.finance.mask(length?: number = 4, parens?: boolean = true, ellipsis?: boolean = true): string
faker.finance.mask() // '(...9711)'
faker.finance.mask(3) // '(...342)'
faker.finance.mask(3, false) // '...236'
faker.finance.mask(3, false, false) // '298'

maskedNumber

Generates a random masked number.

Available since v8.0.0

Parameters

NameTypeDefaultDescription
optionsOrLength?number | { ... }{}

An options object or the length of the unmask number.

optionsOrLength.ellipsis?booleantrue

Whether to prefix the numbers with an ellipsis.

optionsOrLength.length?number4

The length of the unmasked number.

optionsOrLength.parens?booleantrue

Whether to use surrounding parenthesis.

Returns: string

ts
faker.finance.maskedNumber(optionsOrLength?: number | {
  ellipsis: boolean,
  length: number,
  parens: boolean
} = {}): string
faker.finance.maskedNumber() // '(...9711)'
faker.finance.maskedNumber(3) // '(...342)'
faker.finance.maskedNumber({ length: 3 }) // '(...342)'
faker.finance.maskedNumber({ length: 3, parens: false }) // '...236'
faker.finance.maskedNumber({ length: 3, parens: false, ellipsis: false }) // '298'

pin

Generates a random PIN number.

Available since v6.2.0

Parameters

NameTypeDefaultDescription
options?number | { ... }{}

An options object or the length of the PIN.

options.length?number4

The length of the PIN to generate.

Returns: string

Throws: Will throw an error if length is less than 1.

ts
faker.finance.pin(options?: number | {
  length: number
} = {}): string
faker.finance.pin() // '5067'
faker.finance.pin({ length: 6 }) // '213789'
faker.finance.pin(6) // '213789'

routingNumber

Generates a random routing number.

Available since v5.0.0

Returns: string

ts
faker.finance.routingNumber(): string
faker.finance.routingNumber() // '522814402'

transactionDescription

Generates a random transaction description.

Available since v5.1.0

Returns: string

ts
faker.finance.transactionDescription(): string
faker.finance.transactionDescription()
// 'invoice transaction at Kilback - Durgan using card ending with ***(...4316) for UAH 783.82 in account ***16168663'

transactionType

Returns a random transaction type.

Available since v2.0.1

Returns: string

ts
faker.finance.transactionType(): string
faker.finance.transactionType() // 'payment'

Released under the MIT License.