Generate Random Cartoon Avatars With JS And SVG – faces.js
1. Install and import.
# Yarn $ yarn add facesjs # NPM $ npm i facesjs
import { display, generate } from "facesjs"; 2. OR Download and place the JavaScript file faces.js at the bottom of the webpage.
<script src="faces.js"></script>
3. Generate a random cartoon avatar inside a given container.
<div id="example"></div>
const face = generate();
display("example", face); 4. Get the cartoon avatar as a JS object.
var face = faces.generate("example");
console.log(face); 5. Customize the color of the avatar.
const face = generate({
body: { color: "yellow" }
});
// or
faces.display("example", face, {
body: { color: "yellow" }
}); 6. Specify the race: white, black, asian, or brown.
const face = generate({
null,
{race: "white"}
});
7. Generate female faces.
const face = generate({
null,
{gender: "female"}
});
8. convert a face object to an SVG string.
import { faceToSvgString, generate } from "facesjs"; const face = generate(); const svg = faceToSvgString(face);
v5.0.2 (09/09/2025)
v5.0.0/1 (05/06/2025)
v4.3.3 (03/24/2025)
v4.2.2 (08/05/2024)
v4.2.1 (05/15/2024)
v4.2.0 (05/13/2024)
v4.1.1 (05/06/2024)
v4.1.0 (04/23/2024)
v4.0.0 (11/19/2023)
v3.8.2 (03/16/2023)
v3.8.1 (02/26/2023)
v3.8.0 (02/25/2023)
v3.7.4 (07/10/2022)
v3.7.3 (06/17/2022)
v3.7.2 (03/28/2022)
v3.7.0 (03/26/2022)
v3.6.0 (08/18/2021)
v3.5.0 (06/14/2021)
v3.4.0 (03/18/2021)
The post Generate Random Cartoon Avatars With JS And SVG – faces.js appeared first on CSS Script.
GTA 6 pre-orders were rumored to go live today, May 18, but it looks like…
This website uses cookies.