DEV Community

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

Collapse
 
ben profile image
Ben Halpern

We use this Ruby gem:

stympy / faker

A library for generating fake data such as names, addresses, and phone numbers.

logotype a happy-07

Faker

Build Status Gem Version Inline docs Test Coverage Maintainability

This gem is a port of Perl's Data::Faker library that generates fake data.

It comes in very handy for taking screenshots (taking screenshots for my project, Catch the Best was the original impetus for the creation of this gem), having real-looking test data, and having your database populated with more than one or two records while you're doing development.

NOTE

  • While Faker generates data at random, returned values are not guaranteed to be unique by default You must explicity specify when you require unique values, see details Values also can be deterministic if you use the deterministic feature, see details
  • This is the master branch of Faker and may contain changes that are not yet released Please refer the README of your version for the available methods. List of all versions is available here.

Contents

May or may not be convenient in your context, but there are different ports of this available in different coding environments I believe.

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…

Collapse
 
michael profile image
Michael Lee 🍕

Oh wow, this is great. Thanks for sharing Ben!