How code sandbox and stackblitz like online in browser code editors store the files in the browser?
There are various storage APIs available in all major web browsers, Introduced in what's commonly thought of as being part of HTML5. Nowadays, may of these technologies are extending beyond HTML5 - and are growing into standards of their own.
These include:
There are various sizing limitations (such as 5MB for localStorage and sessionStorage).
Learn more about IndexedDB (basically an SQL database), here: https://www.w3.org/TR/IndexedDB/
@Derrick's answer is good when it comes to web storage, but it doesn't explain how the code editors do it. If you are interested in how they do it, that would require a backend. Many cloud/backend storage providers, such as Amazon S3, enable them to store the files and then run them in a server on a VM on their own backend after transferring them to the frontend for you to edit. Once you edit them, it re-saves them to the storage backend. This allows them to persist an indefinite number of files for an indefinite amount of time.