Following is the code for creating auto resize text area using JavaScript −
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<h1>Creating auto-resize text area</h1>
<textarea class="resizeArea"></textarea>
<script>
let BtnEle = document.querySelector(".Btn");
let addrEle = document.querySelectorAll(".addr");
let resizeEle = document.querySelector(".resizeArea");
resizeEle.addEventListener("input", resizeTextArea, false);
function resizeTextArea() {
this.style.height = "auto";
this.style.height = this.scrollHeight + "px";
}
</script>
</body>
</html>Output

On pasting text in the text area, the area will expand as follows −
