Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<div class="container">
<h2>Meme Generator v1.0</h2>
<div class="container">
<input class="input border" id="file" type="file">

<div class="panel">
<input class="input border" id="topLineText" type="text" placeholder="Text oben">
<div class="panel">
<canvas id="image" width="1310" height="844" class="border"></canvas>
<div class="panel">
<input class="input border" id="bottomLineText" type="text" placeholder="Text unten">
<div class="panel">
<button id="saveBtn" class="button black">Speichern</button>


                * { margin: 0; padding: 0; border: 0; font: inherit; box-sizing: border-box; }
html, body { width: 100%; height: 100vh; overflow: hidden; }
main { max-width: 1310px; margin: 0 auto; }
canvas { display: block; max-width: 100%; }


                // xmeme

function textChangeListener (evt) {
var id =;
var text =;
if (id == "topLineText") {
window.topLineText = text; }
else { window.bottomLineText = text; }
redrawMeme(window.imageSrc, window.topLineText, window.bottomLineText);

function redrawMeme(image, topLine, bottomLine) {
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext("2d");
if (image != null){
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
ctx.font = "6rem Impact";
ctx.textAlign = "center";
ctx.strokeStyle = "black";
ctx.lineWidth = 0;
ctx.fillStyle = "white";
if (topLine != null){
ctx.fillText(topLine, canvas.width / 2, 110);
ctx.strokeText(topLine, canvas.width / 2, 110);
if (bottomLine != null){
ctx.fillText(bottomLine, canvas.width / 2, canvas.height -40);
ctx.strokeText(bottomLine, canvas.width / 2, canvas.height -40);

function saveFile() {'canvas').toDataURL());

function handleFileSelect(evt) {
var canvasWidth = 1310;
var canvasHeight = 844;
var file =[0];
var reader = new FileReader();
reader.onload = function(fileObject) {
var data =;
var image = new Image();
image.onload = function() {
window.imageSrc = this;
redrawMeme(window.imageSrc, null, null);
image.src = data;

window.topLineText = "";
window.bottomLineText = "";
var input1 = document.getElementById('topLineText');
var input2 = document.getElementById('bottomLineText');
input1.oninput = textChangeListener;
input2.oninput = textChangeListener;
document.getElementById('file').addEventListener('change', handleFileSelect, false);
document.querySelector('button').addEventListener('click', saveFile, false);