Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <textarea id="myDemoTextArea"></textarea>
<div>
  <a href="#" id="clear_link">Clear</a>
</div>
<div id="table_container"></div>
<textarea id="tableAsJSON"></textarea>
              
            
!

CSS

              
                #myDemoTextArea {
  width: 200px;
  height: 20px;
}

#table_container {
  max-width: 100%;
  width: 450px;
  max-height: 500px;
  overflow-y: scroll;
  padding: 10px;
}

#tableAsJSON {
  width: 450px;
  height: 500px;
}

table.boostrap4_table_head_dark_striped_rounded_compact {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  text-align: left;
  box-sizing: border-box;
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
  background-color: transparent;
}

table.boostrap4_table_head_dark_striped_rounded_compact thead th {
  font-size: 1rem;
  line-height: 1.5;
  border-collapse: collapse;
  box-sizing: border-box;
  text-align: inherit;
  padding: 0.3rem;
  vertical-align: bottom;
  border-bottom: 2px solid #dee2e6;
  color: #fff;
  background-color: #212529;
  border-color: #32383e;
}

table.boostrap4_table_head_dark_striped_rounded_compact td {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  text-align: left;
  border-collapse: collapse;
  box-sizing: border-box;
  padding: 0.3rem;
  vertical-align: top;
  box-shadow: 0 0 1px #212529;
}

table.boostrap4_table_head_dark_striped_rounded_compact
  tbody
  tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.05);
}

table.boostrap4_table_head_dark_striped_rounded_compact th:first-of-type {
  border-top-left-radius: 10px;
}

table.boostrap4_table_head_dark_striped_rounded_compact th:last-of-type {
  border-top-right-radius: 10px;
}

table.boostrap4_table_head_dark_striped_rounded_compact
  tr:last-of-type
  td:first-of-type {
  border-bottom-left-radius: 10px;
}

table.boostrap4_table_head_dark_striped_rounded_compact
  tr:last-of-type
  td:last-of-type {
  border-bottom-right-radius: 10px;
}

              
            
!

JS

              
                let constructTableFromPastedInput = (pastedInput) => {
  let rawRows = pastedInput.split("\n");
  let headRow = "";
  let bodyRows = [];
  rawRows.forEach((rawRow, idx) => {
    let rawRowArray = rawRow.split("\t");
    if (idx == 0) {
      headRow = `<tr><th>${rawRowArray.join("</th><th>")}</th></tr>`;
    } else {
      bodyRows.push(`<tr><td>${rawRowArray.join("</td><td>")}</td></tr>`);
    }
  });
  return `
                <table class="boostrap4_table_head_dark_striped_rounded_compact">
                    <thead>
                        ${headRow}
                    </thead>
                    <tbody>
                        ${bodyRows.join("")}
                    </tbody>
                </table>
            `;
};

let constructJSONFromPastedInput = (pastedInput) => {
  let rawRows = pastedInput.split("\n");
  let headersArray = rawRows[0].split("\t");
  let output = [];
  rawRows.forEach((rawRow, idx) => {
    if (idx > 0) {
      let rowObject = {};
      let values = rawRow.split("\t");
      headersArray.forEach((header, idx) => {
        rowObject[header] = values[idx];
      });
      output.push(rowObject);
    }
  });
  return output;
};

const theTextArea = document.getElementById("myDemoTextArea");

const inputHandler = function (e) {
  let inputText = e.target.value;
  let tableHTML = constructTableFromPastedInput(inputText);
  let tableAsJson = constructJSONFromPastedInput(inputText);
  let prettyJSON = JSON.stringify(tableAsJson, null, 2);
  console.log(prettyJSON);
  document.getElementById("table_container").innerHTML = tableHTML;
  document.getElementById("table_container").style.display = "block";
  document.getElementById("tableAsJSON").value = prettyJSON;
};

theTextArea.addEventListener("input", inputHandler);

document.getElementById("clear_link").addEventListener("click", () => {
  document.getElementById("myDemoTextArea").value = "";
  document.getElementById("table_container").innerHTML = "";
  document.getElementById("table_container").style.display = "none";
  document.getElementById("tableAsJSON").value = "";
});

              
            
!
999px

Console