How to enable script editor web part in SharePoint Online Office 365

Wondering how to enable script editor web part in SharePoint Online Office 365? In this SharePoint tutorial, we will step by step enable script editor web part in SharePoint Online Office 365.

How to enable script editor web part in SharePoint Online Office 365? To enable script editor web part in SharePoint Online Office 365, we need to enable custom script for your Office 365 tenant from the SharePoint Online admin center.

Script editor web part in missing in SharePoint Online

Script editor web part, one of the most popular web part for SharePoint developers, you can easily insert scripts in a SharePoint web part page.

When you create a new SharePoint Online site, the SharePoint online script editor web part usually not available under the Media and Content category.

To verify this, Open any SharePoint web part page, then Edit the page, then click on Insert -> Web Part -> Categories -> Choose Media and Content.

Here you will not be able to see the script editor web part, the SharePoint content editor web part will also be missing like below:

Script editor web part in missing in SharePoint Online

You will not be able to see the script editor web part and content editor web part.

Enable script editor web part in SharePoint online

Now, let us see how we can enable script editor web part in SharePoint Online Office 365.

We can enable from the SharePoint Online admin center.

Open SharePoint Online admin center (https://tsinfo-admin.sharepoint.com/) Then click on Settings -> classic settings page.

enable script editor web part in SharePoint Online
microsfot script editor

This will open the Tenant Settings page.

You can also directly access the Tenant Settings page directly from the browser by accessing the below URL:

https://tsinfo-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx

Here tsinfo is my tenant name, you can change according to your tenant name.

In this page, if you will navigate to the Custom Script section, then you will see by default the below options will be selected:

  • Prevent users from running custom script on personal sites
  • Prevent users from running custom script on self-service created sites

Here change to the below options:

  • Allow users to run custom script on personal sites
  • Allow users to run custom script on self-service created sites

It should looks like below:

enable script editor web part in SharePoint Online office 365
microsoft scripting editor

Note: This may take up to 24 hours to reflect the changes. Sometimes it may take more than that and sometimes it may take 3/4 hours also.

Once the custom script is enabled in the Office 365 tenant. You will be able to see the script editor web part and content editor web part.

script editor web part in SharePoint Online
script editor web part in SharePoint Online

After this you can use the script editor web part in the SharePoint site.

enable script editor web part in SharePoint Online using PowerShell

If the above approach did not work, you can still enable script editor web part in SharePoint Online using PowerShell (SharePoint Online management shell)

Below is the PowerShell script you can use to enable content editor or script editor web part in SharePoint Online.

$username="bijay@tsinfo.onmicrosoft.com"
$userCredential = Get-Credential -UserName $username -Message "Your password"
Connect-SPOService -Url https://tsinfo-admin.sharepoint.com -Credential $userCredential
Set-SPOsite https://tsinfo.sharepoint.com -DenyAddAndCustomizePages 0

Here, tsinfo is my Office 365 tenant id and you can change according to tenant id.

And the account should be a tenant administrator account.

Once you run the PowerShell script, then immediately, the script editor web part and the content editor web part will be available in the SharePoint site.

Important Notes:

  • If you are using a SharePoint Online modern team site, then the script editor web part or content editor web part will not appear.
  • Microsoft is not recommending to use script or content editor web parts, you should use the SharePoint framework development (SPFx).
  • We can not add script editor web part inside a modern SharePoint page.

In this SharePoint tutorial, we learned how to enable script editor web part in SharePoint Online Office 365.

>