DEV Community

Discussion on: Is there a better alternative to lorem ipsum for placeholder copy?

Collapse
 
nathanbland profile image
Nathan Bland

This. For the client side only, or node.js amongst the crowd you can use this version.

Marak / faker.js

generate massive amounts of realistic fake data in Node.js and the browser

faker.js - generate massive amounts of fake data in the browser and node.js

Faker.js

Build Status Coverage Status

npm version

OpenCollective OpenCollective

Demo

rawgit.com/Marak/faker.js/master/e...

Hosted API Microservice

faker.hook.io

  • Supports all Faker API Methods
  • Full-Featured Microservice
  • Hosted by hook.io
curl http://faker.hook.io?property=name.findName&locale=de

Usage

Browser

<script src = "faker.js" type = "text/javascript"></script&gt
<script&gt
  var randomName = faker.name.findName(); // Caitlyn Kerluke
  var randomEmail = faker.internet.email(); // Rusty@arne.info
  var randomCard = faker.helpers.createCard(); // random contact card containing many properties
</script&gt

Node.js

var faker = require('faker');

var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card containing many properties

API

Faker.fake()

faker.js contains a super useful generator method Faker.fake for combining faker API methods using a mustache string format.

Example:

console.log(faker.fake("{{name.lastName}}, {{name.firstName}} {{name.suffix}}"));
// outputs: "Marks, Dean Sr."

This will interpolate the format string with the value of methods…