Skip to main content

Preloaded JavaScript libraries

Information about third-party JavaScript libraries preloaded for use in web apps.

Retool automatically imports the following utility libraries for use across Retool. These libraries are available for use in JavaScript queries and within {{ }} embedded expressions.

NameAliasDescription
Lodash_A modern JavaScript utility library delivering modularity, performance & extras.
Moment.jsmomentParse, validate, manipulate, and display dates and times.
UUIDuuidGenerate and validate RFC-compliant UUIDs.
NumbronumbroConvert, format, and manipulate numbers.
PapaParsePapaParse CSV data, and convert between CSV and JSON.

Lodash

Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It is available using the _ alias.

Live Editor
function chunkArray() {
  
  const array = query1.data; // [1, 2, 3, 4, 5, 6, 7, 8]
  const chunkedArray = _.chunk(query1.data, 2); // [[1, 2], [3, 4], [5, 6], [7, 8]]
  return chunkedArray[2][1];

}
Result
Loading...

Moment

Moment.js is a library for parsing, validating, manipulating, and displaying dates in JavaScript. It is available using the moment alias.

Live Editor
function adjustDate() {

  const selectedDate = dateInput1.value // Current date
  const futureDate = moment(selectedDate).add(7, 'days'); // Add 7 days

  return futureDate.format('MMMM Do YYYY');
  
}
Result
Loading...

UUID

UUID is a library for generating universally unique identifiers (UUID). It is available using the uuid alias.

Live Editor
function generateUuid() {
  
  return uuid.v4();

}
Result
Loading...

Numbro

Numbro is a library for transforming number values. It is available using the numbro alias.

Live Editor
function thousandsSeparator() {
  
  return numbro(1000).format({thousandSeparated: true});

}
Result
Loading...

PapaParse

PapaParse is a library for parsing CSV files. It is available using the Papa alias.

Live Editor
function thousandsSeparator() {

  const csvData = `Order ID,Customer Name,Product,Quantity,Order Date
  1,John Doe,Widget A,3,2024-07-10
  2,Jane Smith,Gadget B,2,2024-07-11
  3,Jim Brown,Thingamajig C,5,2024-07-12
  4,Susan White,Doohickey D,1,2024-07-13
  5,Emily Black,Whatsit E,4,2024-07-14`;

  const jsonData = Papa.parse(csvData); // Convert CSV to JSON

  const customer = jsonData.data[2][1]; // JSON available on `data` property

  return customer;

}
Result
Loading...