Content Service Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Content Service allows scripts to serve text in various formats like text, XML, or JSON.
The ContentService class is used for returning text content from a script.
The MimeType enum defines the various mime types that can be served from a script.
The TextOutput object represents the text content that can be served from a script.
This service allows scripts to serve text in various forms, such as text,XML, or JSON. See also theguide toContent Service. If youdeploy the following script as a web app,you will see "Hello, world!" in the browser:
function doGet() { return ContentService.createTextOutput('Hello, world!');}Classes
| Name | Brief description |
|---|---|
Content | Service for returning text content from a script. |
Mime | An enum for mime types that can be served from a script. |
Text | A TextOutput object that can be served from a script. |
ContentService
Properties
| Property | Type | Description |
|---|---|---|
Mime | Mime |
Methods
| Method | Return type | Brief description |
|---|---|---|
create | Text | Create a newText object. |
create | Text | Create a newText object that can serve the given content. |
MimeType
Properties
| Property | Type | Description |
|---|---|---|
CSV | Enum | CSV Mime Type |
ICAL | Enum | ICAL Mime Type |
JAVASCRIPT | Enum | JAVASCRIPT Mime Type |
JSON | Enum | JSON Mime Type |
TEXT | Enum | TEXT Mime Type |
VCARD | Enum | VCARD Mime Type |
TextOutput
Methods
| Method | Return type | Brief description |
|---|---|---|
append(addedContent) | Text | Appends new content to the content that will be served. |
clear() | Text | Clears the current content. |
download | Text | Tells browsers to download rather than display this content. |
get | String | Gets the content that will be served. |
get | String | Returns the file name to download this file as, or null if it should be displayed rather thandownloaded. |
get | Mime | Get the mime type this content will be served with. |
set | Text | Sets the content that will be served. |
set | Text | Sets the mime type for content that will be served. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.