files/en-us/web/api/filereadersync/readastext/index.md
{{APIRef("File API")}} {{AvailableInWorkers("worker_except_service")}}
The readAsText() method of the {{DOMxRef("FileReaderSync")}} interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects in a synchronous way into a string. This interface is only available in workers as it enables synchronous I/O that could potentially block.
readAsText(blob)
readAsText(blob, encoding)
blob
encoding {{optional_inline}}
iso-8859-1 or UTF-8). If not present, the method will apply a detection algorithm for it.A string representing the input data.
The following exceptions can be raised by this method:
NotFoundError {{domxref("DOMException")}}
SecurityError {{domxref("DOMException")}}
NotReadableError {{domxref("DOMException")}}
EncodingError {{domxref("DOMException")}}
{{Specifications}}
{{Compat}}