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()
.
accountName
Generates a random account name.
Available since v2.0.1
Returns: string
function accountName(): string;
Examples
faker.finance.accountName() // 'Investment Account'
Source
accountNumber
Generates a random account number.
Available since v8.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
optionsOrLength? | number | { ... } | An options object or the length of the account number. | |
optionsOrLength.length? | number | 8 | The length of the account number. |
Returns: string
function accountNumber(
optionsOrLength?:
| number
| {
length?: number;
}
): string;
Examples
faker.finance.accountNumber() // '57654648'
faker.finance.accountNumber(5) // '93755'
faker.finance.accountNumber({ length: 5 }) // '90008'
Source
amount
Generates a random amount between the given bounds (inclusive).
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | An options object. |
options.autoFormat? | boolean | false | If true this method will use |
options.dec? | number | 2 | The number of decimal places for the amount. |
options.max? | number | 1000 | The upper bound for the amount. |
options.min? | number | 0 | The lower bound for the amount. |
options.symbol? | string | '' | The symbol used to prefix the amount. |
Returns: string
function amount(
options: {
min?: number;
max?: number;
dec?: number;
symbol?: string;
autoFormat?: boolean;
} = {}
): string;
Examples
faker.finance.amount() // '548.81'
faker.finance.amount({ min: 5, max: 10 }) // '8.58'
faker.finance.amount({ min: 5, max: 10, dec: 0 }) // '8'
faker.finance.amount({ min: 5, max: 10, dec: 2, symbol: '$' }) // '$7.72'
faker.finance.amount({ min: 5, max: 10, dec: 5, symbol: '', autoFormat: true }) // '7,11827'
Source
bic
Generates a random SWIFT/BIC code based on the ISO-9362 format.
Available since v4.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | Options object. |
options.includeBranchCode? | boolean | faker.datatype.boolean() | Whether to include a three-digit branch code at the end of the generated code. |
Returns: string
function bic(
options: {
includeBranchCode?: boolean;
} = {}
): string;
Examples
faker.finance.bic() // 'SPOLNEFW'
faker.finance.bic({ includeBranchCode: true }) // 'ZJUNMHX20TS'
faker.finance.bic({ includeBranchCode: false }) // 'WZULSD4N'
Source
bitcoinAddress
Generates a random Bitcoin address.
Available since v3.1.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | An optional options object. |
options.network? | 'mainnet' | 'testnet' | 'mainnet' | The bitcoin network ( |
options.type? | 'legacy' | 'segwit' | 'bech32' | 'taproot' | faker.helpers.arrayElement(['legacy','sewgit','bech32','taproot']) | The bitcoin address type ( |
Returns: string
function bitcoinAddress(
options: {
type?: BitcoinAddressFamilyType;
network?: BitcoinNetworkType;
} = {}
): string;
Examples
faker.finance.bitcoinAddress() // 'bc1qmkfngwyetjlx330usvztgs4n5yjf9sgl0mmmyp'
faker.finance.bitcoinAddress({ type: 'bech32' }) // 'bc1dfq2pp75cdlgz476n9g864p57du4u4zgzmr2a4a'
faker.finance.bitcoinAddress({ type: 'bech32', network: 'testnet' }) // 'tb14cf3ql9j4lxcp5qa6l0u0p9ry8lll8ygvqauewl'
Source
creditCardCVV
Generates a random credit card CVV.
Available since v5.0.0
Returns: string
function creditCardCVV(): string;
Examples
faker.finance.creditCardCVV() // '576'
Source
creditCardIssuer
Returns a random credit card issuer.
Available since v6.3.0
Returns: string
function creditCardIssuer(): string;
Examples
faker.finance.creditCardIssuer() // 'jcb'
Source
creditCardNumber
Generates a random credit card number.
Available since v5.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
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
function creditCardNumber(
options?:
| string
| {
issuer?: string;
}
): string;
Examples
faker.finance.creditCardNumber() // '3565-4648-9375-5909'
faker.finance.creditCardNumber({ issuer: 'visa' }) // '4087897471614'
faker.finance.creditCardNumber({ issuer: '63[7-9]#-####-####-###L' }) // '6395-4274-5066-6966'
faker.finance.creditCardNumber('visa') // '4460662133547'
Source
currency
Returns a random currency object, containing code
, name
and symbol
properties.
Available since v8.0.0
Returns: Currency
function currency(): Currency;
Examples
faker.finance.currency() // { 'name': 'Kyat', 'code': 'MMK', 'symbol': '' }
See Also
Source
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
function currencyCode(): string;
Examples
faker.finance.currencyCode() // 'MMK'
Source
currencyName
Returns a random currency name.
Available since v2.0.1
Returns: string
function currencyName(): string;
Examples
faker.finance.currencyName() // 'Kyat'
Source
currencySymbol
Returns a random currency symbol.
Available since v2.0.1
Returns: string
function currencySymbol(): string;
Examples
faker.finance.currencySymbol() // 'руб'
Source
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
function ethereumAddress(): string;
Examples
faker.finance.ethereumAddress() // '0xcfdb9e9df8bbce110cbdfbab2e3eb95bac0dddef'
Source
iban
Generates a random IBAN.
Please note that the generated IBAN might be invalid due to randomly generated bank codes/other country specific validation rules.
Available since v4.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | An options object. |
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? | boolean | false | Return a formatted version of the generated IBAN. |
Returns: string
Throws: Will throw an error if the passed country code is not supported.
function iban(
options: {
formatted?: boolean;
countryCode?: string;
} = {}
): string;
Examples
faker.finance.iban() // 'LI256448975B0UZ411N24'
faker.finance.iban({ formatted: true }) // 'LT33 0696 3607 0035 9002'
faker.finance.iban({ formatted: true, countryCode: 'DE' }) // 'DE25 2200 6004 0046 0003 13'
Source
litecoinAddress
Generates a random Litecoin address.
Available since v5.0.0
Returns: string
function litecoinAddress(): string;
Examples
faker.finance.litecoinAddress() // '3AxqDrTXoMwyV562QMSYNsM7D9Wwqg'
Source
maskedNumber
Deprecated
This method is deprecated and will be removed in a future version.
Use faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*')
or a similar approach instead.
Generates a random masked number.
Available since v8.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
optionsOrLength? | number | { ... } | An options object or the length of the unmask number. | |
optionsOrLength.ellipsis? | boolean | true | Whether to prefix the numbers with an ellipsis. |
optionsOrLength.length? | number | 4 | The length of the unmasked number. |
optionsOrLength.parens? | boolean | true | Whether to use surrounding parenthesis. |
Returns: string
function maskedNumber(
optionsOrLength?:
| number
| {
length?: number;
parens?: boolean;
ellipsis?: boolean;
}
): string;
Examples
faker.finance.maskedNumber() // '(...5765)'
faker.finance.maskedNumber(3) // '(...464)'
faker.finance.maskedNumber({ length: 3 }) // '(...893)'
faker.finance.maskedNumber({ length: 3, parens: false }) // '...755'
faker.finance.maskedNumber({ length: 3, parens: false, ellipsis: false }) // '900'
Source
pin
Generates a random PIN number.
Available since v6.2.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options? | number | { ... } | {} | An options object or the length of the PIN. |
options.length? | number | 4 | The length of the PIN to generate. |
Returns: string
Throws: Will throw an error if length is less than 1.
function pin(
options?:
| number
| {
length?: number;
}
): string;
Examples
faker.finance.pin() // '5765'
faker.finance.pin({ length: 6 }) // '464893'
faker.finance.pin(6) // '755900'
Source
routingNumber
Generates a random routing number.
Available since v5.0.0
Returns: string
function routingNumber(): string;
Examples
faker.finance.routingNumber() // '576546483'
Source
transactionDescription
Generates a random transaction description.
Available since v5.1.0
Returns: string
function transactionDescription(): string;
Examples
faker.finance.transactionDescription() // 'payment at Little Inc with a card ending in ****6489 for INR 791.73 from account ***5590.'
Source
transactionType
Returns a random transaction type.
Available since v2.0.1
Returns: string
function transactionType(): string;
Examples
faker.finance.transactionType() // 'payment'