diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 2cf6f5967ed..1181c5c698e 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -330,7 +330,7 @@ TF_DeprecatedSession* TF_NewDeprecatedSession(const TF_SessionOptions* opt,
     return new TF_DeprecatedSession({session});
   } else {
     DCHECK_EQ(nullptr, session);
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -504,7 +504,7 @@ static void TF_Run_Setup(int noutputs, TF_Tensor** c_outputs,
                          TF_Status* status) {
   status->status = Status::OK();
   for (int i = 0; i < noutputs; ++i) {
-    c_outputs[i] = NULL;
+    c_outputs[i] = nullptr;
   }
 }
 
@@ -2158,7 +2158,7 @@ TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opt,
     return new TF_Session(session, graph);
   } else {
     DCHECK_EQ(nullptr, session);
-    return NULL;
+    return nullptr;
   }
 }
 
diff --git a/tensorflow/contrib/ffmpeg/default/ffmpeg_lib.cc b/tensorflow/contrib/ffmpeg/default/ffmpeg_lib.cc
index a4dd3a642fd..888f5c38a27 100644
--- a/tensorflow/contrib/ffmpeg/default/ffmpeg_lib.cc
+++ b/tensorflow/contrib/ffmpeg/default/ffmpeg_lib.cc
@@ -69,7 +69,7 @@ bool IsBinaryInstalled(const string& binary_name) {
   for (const string& dir : str_util::Split(path, ':')) {
     const string binary_path = io::JoinPath(dir, binary_name);
     char absolute_path[PATH_MAX + 1];
-    if (::realpath(binary_path.c_str(), absolute_path) == NULL) {
+    if (::realpath(binary_path.c_str(), absolute_path) == nullptr) {
       continue;
     }
     struct stat statinfo;
diff --git a/tensorflow/contrib/image/kernels/single_image_random_dot_stereograms_ops.cc b/tensorflow/contrib/image/kernels/single_image_random_dot_stereograms_ops.cc
index 34dc877cfdd..e43f383f8a9 100755
--- a/tensorflow/contrib/image/kernels/single_image_random_dot_stereograms_ops.cc
+++ b/tensorflow/contrib/image/kernels/single_image_random_dot_stereograms_ops.cc
@@ -151,7 +151,7 @@ class SingleImageRandomDotStereogramsOp : public OpKernel {
     BuildZBuffer(inputZ);
 
     // Output a scalar string.
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(
         context,
         context->allocate_output(
diff --git a/tensorflow/core/common_runtime/gpu/gpu_tracer.cc b/tensorflow/core/common_runtime/gpu/gpu_tracer.cc
index 54d8a3d80d6..d42a52cc5da 100644
--- a/tensorflow/core/common_runtime/gpu/gpu_tracer.cc
+++ b/tensorflow/core/common_runtime/gpu/gpu_tracer.cc
@@ -226,7 +226,7 @@ void CUPTIManager::InternalBufferCompleted(CUcontext ctx, uint32_t streamId,
                                            size_t validSize) {
   VLOG(2) << "BufferCompleted";
   CUptiResult status;
-  CUpti_Activity *record = NULL;
+  CUpti_Activity *record = nullptr;
   mutex_lock l(mu_);  // Hold mu_ while using client_.
   if (client_ && validSize > 0) {
     do {
diff --git a/tensorflow/core/distributed_runtime/message_wrappers.cc b/tensorflow/core/distributed_runtime/message_wrappers.cc
index f3bab589a19..b3e89e5d4cc 100644
--- a/tensorflow/core/distributed_runtime/message_wrappers.cc
+++ b/tensorflow/core/distributed_runtime/message_wrappers.cc
@@ -516,7 +516,7 @@ CostGraphDef* InMemoryRunGraphResponse::mutable_cost_graph() {
 
 RunGraphResponse* InMemoryRunGraphResponse::get_proto() {
   LOG(FATAL) << "Cannot get a mutable protobuf for an InMemoryRunGraphResponse";
-  return NULL;
+  return nullptr;
 }
 
 size_t OwnedProtoRunGraphResponse::num_recvs() const {
@@ -635,7 +635,7 @@ RunMetadata* InMemoryRunStepResponse::mutable_metadata() { return &metadata_; }
 
 RunStepResponse* InMemoryRunStepResponse::get_proto() {
   LOG(FATAL) << "Cannot get a mutable protobuf for an InMemoryRunStepResponse";
-  return NULL;
+  return nullptr;
 }
 
 size_t OwnedProtoRunStepResponse::num_tensors() const {
diff --git a/tensorflow/core/kernels/debug_ops_test.cc b/tensorflow/core/kernels/debug_ops_test.cc
index 626106f9824..037272e009d 100644
--- a/tensorflow/core/kernels/debug_ops_test.cc
+++ b/tensorflow/core/kernels/debug_ops_test.cc
@@ -97,7 +97,7 @@ TEST_F(DebugIdentityOpTest, Int32Success_6_FileURLs) {
     DIR* dir = opendir(dump_roots[i].c_str());
     struct dirent* ent;
     int dump_files_found = 0;
-    while ((ent = readdir(dir)) != NULL) {
+    while ((ent = readdir(dir)) != nullptr) {
       if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) {
         dump_files_found++;
 
diff --git a/tensorflow/core/kernels/encode_jpeg_op.cc b/tensorflow/core/kernels/encode_jpeg_op.cc
index fe63c5ef970..8e021b92563 100644
--- a/tensorflow/core/kernels/encode_jpeg_op.cc
+++ b/tensorflow/core/kernels/encode_jpeg_op.cc
@@ -119,7 +119,7 @@ class EncodeJpegOp : public OpKernel {
     }
 
     // Encode image to jpeg string
-    Tensor* output = NULL;
+    Tensor* output = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, TensorShape({}), &output));
     OP_REQUIRES(context,
diff --git a/tensorflow/core/kernels/encode_png_op.cc b/tensorflow/core/kernels/encode_png_op.cc
index f21ab3a8170..8fcda25e692 100644
--- a/tensorflow/core/kernels/encode_png_op.cc
+++ b/tensorflow/core/kernels/encode_png_op.cc
@@ -73,7 +73,7 @@ class EncodePngOp : public OpKernel {
                     "image must have 1, 2, 3, or 4 channels, got ", channels));
 
     // Encode image to png string
-    Tensor* output = NULL;
+    Tensor* output = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, TensorShape({}), &output));
     if (desired_channel_bits_ == 8) {
diff --git a/tensorflow/core/kernels/encode_wav_op.cc b/tensorflow/core/kernels/encode_wav_op.cc
index ad5835aeb46..aed095076b9 100644
--- a/tensorflow/core/kernels/encode_wav_op.cc
+++ b/tensorflow/core/kernels/encode_wav_op.cc
@@ -52,7 +52,7 @@ class EncodeWavOp : public OpKernel {
     const int32 sample_count = static_cast<int32>(audio.dim_size(0));
 
     // Encode audio to wav string.
-    Tensor* output = NULL;
+    Tensor* output = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, TensorShape({}), &output));
     OP_REQUIRES_OK(context,
diff --git a/tensorflow/core/kernels/fact_op.cc b/tensorflow/core/kernels/fact_op.cc
index f1ab4c4a4de..1754c4a38cb 100644
--- a/tensorflow/core/kernels/fact_op.cc
+++ b/tensorflow/core/kernels/fact_op.cc
@@ -82,7 +82,7 @@ class FactOpKernel : public OpKernel {
  protected:
   void Compute(OpKernelContext* context, const char* const facts[],
                uint64 count) {
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(
         context, context->allocate_output(0, TensorShape({}), &output_tensor));
     auto output = output_tensor->template scalar<string>();
diff --git a/tensorflow/core/lib/core/arena.cc b/tensorflow/core/lib/core/arena.cc
index ef1b9a5468c..2a04f7bd39d 100644
--- a/tensorflow/core/lib/core/arena.cc
+++ b/tensorflow/core/lib/core/arena.cc
@@ -44,9 +44,9 @@ namespace core {
 Arena::Arena(const size_t block_size)
     : remaining_(0),
       block_size_(block_size),
-      freestart_(NULL),  // set for real in Reset()
+      freestart_(nullptr),  // set for real in Reset()
       blocks_alloced_(1),
-      overflow_blocks_(NULL) {
+      overflow_blocks_(nullptr) {
   assert(block_size > kDefaultAlignment);
 
   first_blocks_[0].mem =
@@ -59,7 +59,7 @@ Arena::Arena(const size_t block_size)
 
 Arena::~Arena() {
   FreeBlocks();
-  assert(overflow_blocks_ == NULL);  // FreeBlocks() should do that
+  assert(overflow_blocks_ == nullptr);  // FreeBlocks() should do that
   // The first X blocks stay allocated always by default.  Delete them now.
   for (size_t i = 0; i < blocks_alloced_; ++i) {
     port::AlignedFree(first_blocks_[i].mem);
@@ -152,7 +152,7 @@ Arena::AllocatedBlock* Arena::AllocNewBlock(const size_t block_size,
     // Use one of the pre-allocated blocks
     block = &first_blocks_[blocks_alloced_++];
   } else {  // oops, out of space, move to the vector
-    if (overflow_blocks_ == NULL)
+    if (overflow_blocks_ == nullptr)
       overflow_blocks_ = new std::vector<AllocatedBlock>;
     // Adds another block to the vector.
     overflow_blocks_->resize(overflow_blocks_->size() + 1);
@@ -185,10 +185,10 @@ Arena::AllocatedBlock* Arena::AllocNewBlock(const size_t block_size,
   block->mem = reinterpret_cast<char*>(
       port::AlignedMalloc(adjusted_block_size, adjusted_alignment));
   block->size = adjusted_block_size;
-  CHECK(NULL != block->mem) << "block_size=" << block_size
-                            << " adjusted_block_size=" << adjusted_block_size
-                            << " alignment=" << alignment
-                            << " adjusted_alignment=" << adjusted_alignment;
+  CHECK(nullptr != block->mem) << "block_size=" << block_size
+                               << " adjusted_block_size=" << adjusted_block_size
+                               << " alignment=" << alignment
+                               << " adjusted_alignment=" << adjusted_alignment;
 
   return block;
 }
@@ -205,7 +205,7 @@ Arena::AllocatedBlock* Arena::AllocNewBlock(const size_t block_size,
 
 void* Arena::GetMemoryFallback(const size_t size, const int alignment) {
   if (0 == size) {
-    return NULL;  // stl/stl_alloc.h says this is okay
+    return nullptr;  // stl/stl_alloc.h says this is okay
   }
 
   // alignment must be a positive power of 2.
@@ -246,17 +246,17 @@ void* Arena::GetMemoryFallback(const size_t size, const int alignment) {
 void Arena::FreeBlocks() {
   for (size_t i = 1; i < blocks_alloced_; ++i) {  // keep first block alloced
     port::AlignedFree(first_blocks_[i].mem);
-    first_blocks_[i].mem = NULL;
+    first_blocks_[i].mem = nullptr;
     first_blocks_[i].size = 0;
   }
   blocks_alloced_ = 1;
-  if (overflow_blocks_ != NULL) {
+  if (overflow_blocks_ != nullptr) {
     std::vector<AllocatedBlock>::iterator it;
     for (it = overflow_blocks_->begin(); it != overflow_blocks_->end(); ++it) {
       port::AlignedFree(it->mem);
     }
     delete overflow_blocks_;  // These should be used very rarely
-    overflow_blocks_ = NULL;
+    overflow_blocks_ = nullptr;
   }
 }
 
diff --git a/tensorflow/core/lib/core/coding.cc b/tensorflow/core/lib/core/coding.cc
index 21fb548053c..bb95c274104 100644
--- a/tensorflow/core/lib/core/coding.cc
+++ b/tensorflow/core/lib/core/coding.cc
@@ -148,14 +148,14 @@ const char* GetVarint32PtrFallback(const char* p, const char* limit,
       return reinterpret_cast<const char*>(p);
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 bool GetVarint32(StringPiece* input, uint32* value) {
   const char* p = input->data();
   const char* limit = p + input->size();
   const char* q = GetVarint32Ptr(p, limit, value);
-  if (q == NULL) {
+  if (q == nullptr) {
     return false;
   } else {
     *input = StringPiece(q, limit - q);
@@ -177,14 +177,14 @@ const char* GetVarint64Ptr(const char* p, const char* limit, uint64* value) {
       return reinterpret_cast<const char*>(p);
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 bool GetVarint64(StringPiece* input, uint64* value) {
   const char* p = input->data();
   const char* limit = p + input->size();
   const char* q = GetVarint64Ptr(p, limit, value);
-  if (q == NULL) {
+  if (q == nullptr) {
     return false;
   } else {
     *input = StringPiece(q, limit - q);
diff --git a/tensorflow/core/lib/core/coding_test.cc b/tensorflow/core/lib/core/coding_test.cc
index 9e5710d9b76..9efe3d8ec10 100644
--- a/tensorflow/core/lib/core/coding_test.cc
+++ b/tensorflow/core/lib/core/coding_test.cc
@@ -125,7 +125,7 @@ TEST(Coding, Varint32) {
     uint32 expected = (i / 32) << (i % 32);
     uint32 actual;
     p = GetVarint32Ptr(p, limit, &actual);
-    ASSERT_TRUE(p != NULL);
+    ASSERT_TRUE(p != nullptr);
     ASSERT_EQ(expected, actual);
   }
   ASSERT_EQ(p, s.data() + s.size());
@@ -158,7 +158,7 @@ TEST(Coding, Varint64) {
     ASSERT_TRUE(p < limit);
     uint64 actual;
     p = GetVarint64Ptr(p, limit, &actual);
-    ASSERT_TRUE(p != NULL);
+    ASSERT_TRUE(p != nullptr);
     ASSERT_EQ(values[i], actual);
   }
   ASSERT_EQ(p, limit);
@@ -168,7 +168,7 @@ TEST(Coding, Varint32Overflow) {
   uint32 result;
   string input("\x81\x82\x83\x84\x85\x11");
   ASSERT_TRUE(GetVarint32Ptr(input.data(), input.data() + input.size(),
-                             &result) == NULL);
+                             &result) == nullptr);
 }
 
 TEST(Coding, Varint32Truncation) {
@@ -177,9 +177,10 @@ TEST(Coding, Varint32Truncation) {
   PutVarint32(&s, large_value);
   uint32 result;
   for (size_t len = 0; len < s.size() - 1; len++) {
-    ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + len, &result) == NULL);
+    ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + len, &result) == nullptr);
   }
-  ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + s.size(), &result) != NULL);
+  ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + s.size(), &result) !=
+              nullptr);
   ASSERT_EQ(large_value, result);
 }
 
@@ -187,7 +188,7 @@ TEST(Coding, Varint64Overflow) {
   uint64 result;
   string input("\x81\x82\x83\x84\x85\x81\x82\x83\x84\x85\x11");
   ASSERT_TRUE(GetVarint64Ptr(input.data(), input.data() + input.size(),
-                             &result) == NULL);
+                             &result) == nullptr);
 }
 
 TEST(Coding, Varint64Truncation) {
@@ -196,9 +197,10 @@ TEST(Coding, Varint64Truncation) {
   PutVarint64(&s, large_value);
   uint64 result;
   for (size_t len = 0; len < s.size() - 1; len++) {
-    ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + len, &result) == NULL);
+    ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + len, &result) == nullptr);
   }
-  ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + s.size(), &result) != NULL);
+  ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + s.size(), &result) !=
+              nullptr);
   ASSERT_EQ(large_value, result);
 }
 
diff --git a/tensorflow/core/lib/core/status.cc b/tensorflow/core/lib/core/status.cc
index 237c69fb5d7..bbb68ef8d48 100644
--- a/tensorflow/core/lib/core/status.cc
+++ b/tensorflow/core/lib/core/status.cc
@@ -46,7 +46,7 @@ const string& Status::empty_string() {
 }
 
 string Status::ToString() const {
-  if (state_ == NULL) {
+  if (state_ == nullptr) {
     return "OK";
   } else {
     char tmp[30];
diff --git a/tensorflow/core/lib/core/stringpiece.cc b/tensorflow/core/lib/core/stringpiece.cc
index 12f9fe38290..984f4404ce2 100644
--- a/tensorflow/core/lib/core/stringpiece.cc
+++ b/tensorflow/core/lib/core/stringpiece.cc
@@ -40,7 +40,7 @@ size_t StringPiece::find(char c, size_t pos) const {
   }
   const char* result =
       reinterpret_cast<const char*>(memchr(data_ + pos, c, size_ - pos));
-  return result != NULL ? result - data_ : npos;
+  return result != nullptr ? result - data_ : npos;
 }
 
 // Search range is [0..pos] inclusive.  If pos == npos, search everything.
diff --git a/tensorflow/core/lib/gtl/inlined_vector_test.cc b/tensorflow/core/lib/gtl/inlined_vector_test.cc
index 6e3c083f58a..ef1d44fa944 100644
--- a/tensorflow/core/lib/gtl/inlined_vector_test.cc
+++ b/tensorflow/core/lib/gtl/inlined_vector_test.cc
@@ -65,7 +65,7 @@ class RefCounted {
 
   ~RefCounted() {
     Unref();
-    count_ = NULL;
+    count_ = nullptr;
   }
 
   friend void swap(RefCounted& a, RefCounted& b) {
@@ -81,7 +81,7 @@ class RefCounted {
   }
 
   void Ref() const {
-    CHECK(count_ != NULL);
+    CHECK(count_ != nullptr);
     ++(*count_);
     VLOG(5) << "[Ref: refcount " << *count_ << " on count @" << count_ << "]";
   }
diff --git a/tensorflow/core/lib/gtl/top_n_test.cc b/tensorflow/core/lib/gtl/top_n_test.cc
index 0f2325e6faf..fae85570dc0 100644
--- a/tensorflow/core/lib/gtl/top_n_test.cc
+++ b/tensorflow/core/lib/gtl/top_n_test.cc
@@ -172,13 +172,13 @@ TEST(TopNTest, Ptr) {
   LOG(INFO) << "Testing 2-argument push()";
   TopN<string *> topn(3);
   for (int i = 0; i < 8; ++i) {
-    string *dropped = NULL;
+    string *dropped = nullptr;
     topn.push(new string(std::to_string(i)), &dropped);
     delete dropped;
   }
 
   for (int i = 8; i > 0; --i) {
-    string *dropped = NULL;
+    string *dropped = nullptr;
     topn.push(new string(std::to_string(i)), &dropped);
     delete dropped;
   }
diff --git a/tensorflow/core/lib/io/block.cc b/tensorflow/core/lib/io/block.cc
index 30c842208f3..1fa26d91470 100644
--- a/tensorflow/core/lib/io/block.cc
+++ b/tensorflow/core/lib/io/block.cc
@@ -64,7 +64,7 @@ Block::~Block() {
 static inline const char* DecodeEntry(const char* p, const char* limit,
                                       uint32* shared, uint32* non_shared,
                                       uint32* value_length) {
-  if (limit - p < 3) return NULL;
+  if (limit - p < 3) return nullptr;
   *shared = reinterpret_cast<const unsigned char*>(p)[0];
   *non_shared = reinterpret_cast<const unsigned char*>(p)[1];
   *value_length = reinterpret_cast<const unsigned char*>(p)[2];
@@ -72,13 +72,15 @@ static inline const char* DecodeEntry(const char* p, const char* limit,
     // Fast path: all three values are encoded in one byte each
     p += 3;
   } else {
-    if ((p = core::GetVarint32Ptr(p, limit, shared)) == NULL) return NULL;
-    if ((p = core::GetVarint32Ptr(p, limit, non_shared)) == NULL) return NULL;
-    if ((p = core::GetVarint32Ptr(p, limit, value_length)) == NULL) return NULL;
+    if ((p = core::GetVarint32Ptr(p, limit, shared)) == nullptr) return nullptr;
+    if ((p = core::GetVarint32Ptr(p, limit, non_shared)) == nullptr)
+      return nullptr;
+    if ((p = core::GetVarint32Ptr(p, limit, value_length)) == nullptr)
+      return nullptr;
   }
 
   if (static_cast<uint32>(limit - p) < (*non_shared + *value_length)) {
-    return NULL;
+    return nullptr;
   }
   return p;
 }
@@ -158,7 +160,7 @@ class Block::Iter : public Iterator {
       const char* key_ptr =
           DecodeEntry(data_ + region_offset, data_ + restarts_, &shared,
                       &non_shared, &value_length);
-      if (key_ptr == NULL || (shared != 0)) {
+      if (key_ptr == nullptr || (shared != 0)) {
         CorruptionError();
         return;
       }
@@ -214,7 +216,7 @@ class Block::Iter : public Iterator {
     // Decode next entry
     uint32 shared, non_shared, value_length;
     p = DecodeEntry(p, limit, &shared, &non_shared, &value_length);
-    if (p == NULL || key_.size() < shared) {
+    if (p == nullptr || key_.size() < shared) {
       CorruptionError();
       return false;
     } else {
diff --git a/tensorflow/core/lib/io/iterator.cc b/tensorflow/core/lib/io/iterator.cc
index 95d2da402b8..60f9981c2f2 100644
--- a/tensorflow/core/lib/io/iterator.cc
+++ b/tensorflow/core/lib/io/iterator.cc
@@ -19,14 +19,14 @@ namespace tensorflow {
 namespace table {
 
 Iterator::Iterator() {
-  cleanup_.function = NULL;
-  cleanup_.next = NULL;
+  cleanup_.function = nullptr;
+  cleanup_.next = nullptr;
 }
 
 Iterator::~Iterator() {
-  if (cleanup_.function != NULL) {
+  if (cleanup_.function != nullptr) {
     (*cleanup_.function)(cleanup_.arg1, cleanup_.arg2);
-    for (Cleanup* c = cleanup_.next; c != NULL;) {
+    for (Cleanup* c = cleanup_.next; c != nullptr;) {
       (*c->function)(c->arg1, c->arg2);
       Cleanup* next = c->next;
       delete c;
@@ -36,9 +36,9 @@ Iterator::~Iterator() {
 }
 
 void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) {
-  assert(func != NULL);
+  assert(func != nullptr);
   Cleanup* c;
-  if (cleanup_.function == NULL) {
+  if (cleanup_.function == nullptr) {
     c = &cleanup_;
   } else {
     c = new Cleanup;
diff --git a/tensorflow/core/lib/io/table.cc b/tensorflow/core/lib/io/table.cc
index 41eb38fe194..1ef7bb6ccda 100644
--- a/tensorflow/core/lib/io/table.cc
+++ b/tensorflow/core/lib/io/table.cc
@@ -40,7 +40,7 @@ struct Table::Rep {
 
 Status Table::Open(const Options& options, RandomAccessFile* file, uint64 size,
                    Table** table) {
-  *table = NULL;
+  *table = nullptr;
   if (size < Footer::kEncodedLength) {
     return errors::DataLoss("file is too short to be an sstable");
   }
@@ -57,7 +57,7 @@ Status Table::Open(const Options& options, RandomAccessFile* file, uint64 size,
 
   // Read the index block
   BlockContents contents;
-  Block* index_block = NULL;
+  Block* index_block = nullptr;
   if (s.ok()) {
     s = ReadBlock(file, footer.index_handle(), &contents);
     if (s.ok()) {
@@ -94,7 +94,7 @@ static void DeleteBlock(void* arg, void* ignored) {
 Iterator* Table::BlockReader(void* arg, const StringPiece& index_value) {
   Table* table = reinterpret_cast<Table*>(arg);
   //  Cache* block_cache = table->rep_->options.block_cache;
-  Block* block = NULL;
+  Block* block = nullptr;
   //  Cache::Handle* cache_handle = NULL;
 
   BlockHandle handle;
@@ -112,9 +112,9 @@ Iterator* Table::BlockReader(void* arg, const StringPiece& index_value) {
   }
 
   Iterator* iter;
-  if (block != NULL) {
+  if (block != nullptr) {
     iter = block->NewIterator();
-    iter->RegisterCleanup(&DeleteBlock, block, NULL);
+    iter->RegisterCleanup(&DeleteBlock, block, nullptr);
   } else {
     iter = NewErrorIterator(s);
   }
diff --git a/tensorflow/core/lib/io/table_test.cc b/tensorflow/core/lib/io/table_test.cc
index d2002d69c4d..d479c2d5339 100644
--- a/tensorflow/core/lib/io/table_test.cc
+++ b/tensorflow/core/lib/io/table_test.cc
@@ -177,11 +177,11 @@ class Constructor {
 
 class BlockConstructor : public Constructor {
  public:
-  BlockConstructor() : block_(NULL) {}
+  BlockConstructor() : block_(nullptr) {}
   ~BlockConstructor() override { delete block_; }
   Status FinishImpl(const Options& options, const KVMap& data) override {
     delete block_;
-    block_ = NULL;
+    block_ = nullptr;
     BlockBuilder builder(&options);
 
     for (KVMap::const_iterator it = data.begin(); it != data.end(); ++it) {
@@ -205,7 +205,7 @@ class BlockConstructor : public Constructor {
 
 class TableConstructor : public Constructor {
  public:
-  TableConstructor() : source_(NULL), table_(NULL) {}
+  TableConstructor() : source_(nullptr), table_(nullptr) {}
   ~TableConstructor() override { Reset(); }
   Status FinishImpl(const Options& options, const KVMap& data) override {
     Reset();
@@ -239,8 +239,8 @@ class TableConstructor : public Constructor {
   void Reset() {
     delete table_;
     delete source_;
-    table_ = NULL;
-    source_ = NULL;
+    table_ = nullptr;
+    source_ = nullptr;
   }
 
   StringSource* source_;
@@ -262,11 +262,11 @@ static const int kNumTestArgs = sizeof(kTestArgList) / sizeof(kTestArgList[0]);
 
 class Harness : public ::testing::Test {
  public:
-  Harness() : constructor_(NULL) {}
+  Harness() : constructor_(nullptr) {}
 
   void Init(const TestArgs& args) {
     delete constructor_;
-    constructor_ = NULL;
+    constructor_ = nullptr;
     options_ = Options();
 
     options_.block_restart_interval = args.restart_interval;
diff --git a/tensorflow/core/lib/io/two_level_iterator.cc b/tensorflow/core/lib/io/two_level_iterator.cc
index 8a1034ceea2..ad66ae40d80 100644
--- a/tensorflow/core/lib/io/two_level_iterator.cc
+++ b/tensorflow/core/lib/io/two_level_iterator.cc
@@ -54,7 +54,7 @@ class TwoLevelIterator : public Iterator {
     // Status
     if (!index_iter_->status().ok()) {
       return index_iter_->status();
-    } else if (data_iter_ != NULL && !data_iter_->status().ok()) {
+    } else if (data_iter_ != nullptr && !data_iter_->status().ok()) {
       return data_iter_->status();
     } else {
       return status_;
@@ -84,7 +84,7 @@ TwoLevelIterator::TwoLevelIterator(Iterator* index_iter,
     : block_function_(block_function),
       arg_(arg),
       index_iter_(index_iter),
-      data_iter_(NULL) {}
+      data_iter_(nullptr) {}
 
 TwoLevelIterator::~TwoLevelIterator() {
   delete index_iter_;
@@ -94,14 +94,14 @@ TwoLevelIterator::~TwoLevelIterator() {
 void TwoLevelIterator::Seek(const StringPiece& target) {
   index_iter_->Seek(target);
   InitDataBlock();
-  if (data_iter_ != NULL) data_iter_->Seek(target);
+  if (data_iter_ != nullptr) data_iter_->Seek(target);
   SkipEmptyDataBlocksForward();
 }
 
 void TwoLevelIterator::SeekToFirst() {
   index_iter_->SeekToFirst();
   InitDataBlock();
-  if (data_iter_ != NULL) data_iter_->SeekToFirst();
+  if (data_iter_ != nullptr) data_iter_->SeekToFirst();
   SkipEmptyDataBlocksForward();
 }
 
@@ -112,20 +112,20 @@ void TwoLevelIterator::Next() {
 }
 
 void TwoLevelIterator::SkipEmptyDataBlocksForward() {
-  while (data_iter_ == NULL || !data_iter_->Valid()) {
+  while (data_iter_ == nullptr || !data_iter_->Valid()) {
     // Move to next block
     if (!index_iter_->Valid()) {
-      SetDataIterator(NULL);
+      SetDataIterator(nullptr);
       return;
     }
     index_iter_->Next();
     InitDataBlock();
-    if (data_iter_ != NULL) data_iter_->SeekToFirst();
+    if (data_iter_ != nullptr) data_iter_->SeekToFirst();
   }
 }
 
 void TwoLevelIterator::SetDataIterator(Iterator* data_iter) {
-  if (data_iter_ != NULL) {
+  if (data_iter_ != nullptr) {
     SaveError(data_iter_->status());
     delete data_iter_;
   }
@@ -134,10 +134,10 @@ void TwoLevelIterator::SetDataIterator(Iterator* data_iter) {
 
 void TwoLevelIterator::InitDataBlock() {
   if (!index_iter_->Valid()) {
-    SetDataIterator(NULL);
+    SetDataIterator(nullptr);
   } else {
     StringPiece handle = index_iter_->value();
-    if (data_iter_ != NULL && handle.compare(data_block_handle_) == 0) {
+    if (data_iter_ != nullptr && handle.compare(data_block_handle_) == 0) {
       // data_iter_ is already constructed with this iterator, so
       // no need to change anything
     } else {
diff --git a/tensorflow/core/lib/io/zlib_inputstream.cc b/tensorflow/core/lib/io/zlib_inputstream.cc
index 6b64011cc34..d019b65510f 100644
--- a/tensorflow/core/lib/io/zlib_inputstream.cc
+++ b/tensorflow/core/lib/io/zlib_inputstream.cc
@@ -60,7 +60,7 @@ void ZlibInputStream::InitZlibBuffer() {
   int status = inflateInit2(z_stream_.get(), zlib_options_.window_bits);
   if (status != Z_OK) {
     LOG(FATAL) << "inflateInit failed with status " << status;
-    z_stream_.reset(NULL);
+    z_stream_.reset(nullptr);
   } else {
     z_stream_->next_in = z_stream_input_.get();
     z_stream_->next_out = z_stream_output_.get();
@@ -180,7 +180,7 @@ Status ZlibInputStream::Inflate() {
   if (error != Z_OK && error != Z_STREAM_END) {
     string error_string =
         strings::StrCat("inflate() failed with error ", error);
-    if (z_stream_->msg != NULL) {
+    if (z_stream_->msg != nullptr) {
       strings::StrAppend(&error_string, ": ", z_stream_->msg);
     }
     return errors::DataLoss(error_string);
diff --git a/tensorflow/core/lib/io/zlib_outputbuffer.cc b/tensorflow/core/lib/io/zlib_outputbuffer.cc
index a65b36b64d4..5901504b87c 100644
--- a/tensorflow/core/lib/io/zlib_outputbuffer.cc
+++ b/tensorflow/core/lib/io/zlib_outputbuffer.cc
@@ -58,7 +58,7 @@ Status ZlibOutputBuffer::Init() {
                    zlib_options_.compression_method, zlib_options_.window_bits,
                    zlib_options_.mem_level, zlib_options_.compression_strategy);
   if (status != Z_OK) {
-    z_stream_.reset(NULL);
+    z_stream_.reset(nullptr);
     return errors::InvalidArgument("deflateInit failed with status", status);
   }
   z_stream_->next_in = z_stream_input_.get();
@@ -206,7 +206,7 @@ Status ZlibOutputBuffer::Close() {
   TF_RETURN_IF_ERROR(DeflateBuffered(true));
   TF_RETURN_IF_ERROR(FlushOutputBufferToFile());
   deflateEnd(z_stream_.get());
-  z_stream_.reset(NULL);
+  z_stream_.reset(nullptr);
   return Status::OK();
 }
 
@@ -217,7 +217,7 @@ Status ZlibOutputBuffer::Deflate(int flush) {
     return Status::OK();
   }
   string error_string = strings::StrCat("deflate() failed with error ", error);
-  if (z_stream_->msg != NULL) {
+  if (z_stream_->msg != nullptr) {
     strings::StrAppend(&error_string, ": ", z_stream_->msg);
   }
   return errors::DataLoss(error_string);
diff --git a/tensorflow/core/lib/jpeg/jpeg_handle.cc b/tensorflow/core/lib/jpeg/jpeg_handle.cc
index ce639870926..0ab9249cf59 100644
--- a/tensorflow/core/lib/jpeg/jpeg_handle.cc
+++ b/tensorflow/core/lib/jpeg/jpeg_handle.cc
@@ -79,14 +79,14 @@ void MemTermDestination(j_compress_ptr cinfo) {
 
 // -----------------------------------------------------------------------------
 void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize) {
-  SetDest(cinfo, buffer, bufsize, NULL);
+  SetDest(cinfo, buffer, bufsize, nullptr);
 }
 
 // -----------------------------------------------------------------------------
 void SetDest(j_compress_ptr cinfo, void *buffer, int bufsize,
              string *destination) {
   MemDestMgr *dest;
-  if (cinfo->dest == NULL) {
+  if (cinfo->dest == nullptr) {
     cinfo->dest = reinterpret_cast<struct jpeg_destination_mgr *>(
         (*cinfo->mem->alloc_small)(reinterpret_cast<j_common_ptr>(cinfo),
                                    JPOOL_PERMANENT, sizeof(MemDestMgr)));
@@ -177,7 +177,7 @@ void SetSrc(j_decompress_ptr cinfo, const void *data,
   src->data = reinterpret_cast<const unsigned char *>(data);
   src->datasize = datasize;
   src->pub.bytes_in_buffer = 0;
-  src->pub.next_input_byte = NULL;
+  src->pub.next_input_byte = nullptr;
   src->try_recover_truncated_jpeg = try_recover_truncated_jpeg;
 }
 
diff --git a/tensorflow/core/lib/jpeg/jpeg_mem.cc b/tensorflow/core/lib/jpeg/jpeg_mem.cc
index e27904ea12a..3bd754cf76c 100644
--- a/tensorflow/core/lib/jpeg/jpeg_mem.cc
+++ b/tensorflow/core/lib/jpeg/jpeg_mem.cc
@@ -90,7 +90,7 @@ uint8* UncompressLow(const void* srcdata, FewerArgsForCompiler* argball) {
   }
 
   // if empty image, return
-  if (datasize == 0 || srcdata == NULL) return nullptr;
+  if (datasize == 0 || srcdata == nullptr) return nullptr;
 
   // Declare temporary buffer pointer here so that we can free on error paths
   JSAMPLE* tempdata = nullptr;
@@ -183,7 +183,7 @@ uint8* UncompressLow(const void* srcdata, FewerArgsForCompiler* argball) {
 
   // Temporary buffer used for CMYK -> RGB conversion.
   const bool use_cmyk = (cinfo.out_color_space == JCS_CMYK);
-  tempdata = use_cmyk ? new JSAMPLE[cinfo.output_width * 4] : NULL;
+  tempdata = use_cmyk ? new JSAMPLE[cinfo.output_width * 4] : nullptr;
 
   // If there is an error reading a line, this aborts the reading.
   // Save the fraction of the image that has been read.
@@ -246,7 +246,7 @@ uint8* UncompressLow(const void* srcdata, FewerArgsForCompiler* argball) {
     output_line += stride;
   }
   delete[] tempdata;
-  tempdata = NULL;
+  tempdata = nullptr;
 
   // Convert the RGB data to RGBA, with alpha set to 0xFF to indicate
   // opacity.
@@ -345,10 +345,10 @@ uint8* Uncompress(const void* srcdata, int datasize,
       argball.height_ == 0
           ? 1.0
           : (static_cast<float>(argball.height_read_) / argball.height_);
-  if (dstdata == NULL ||
+  if (dstdata == nullptr ||
       fraction_read < std::min(1.0f, flags.min_acceptable_fraction)) {
     // Major failure, none or too-partial read returned; get out
-    return NULL;
+    return nullptr;
   }
 
   // If there was an error in reading the jpeg data,
@@ -366,7 +366,7 @@ uint8* Uncompress(const void* srcdata, int datasize,
 uint8* Uncompress(const void* srcdata, int datasize,
                   const UncompressFlags& flags, int* pwidth, int* pheight,
                   int* pcomponents, int64* nwarn) {
-  uint8* buffer = NULL;
+  uint8* buffer = nullptr;
   uint8* result =
       Uncompress(srcdata, datasize, flags, nwarn,
                  [=, &buffer](int width, int height, int components) {
@@ -391,7 +391,7 @@ bool GetImageInfo(const void* srcdata, int datasize, int* width, int* height,
   if (components) *components = 0;
 
   // If empty image, return
-  if (datasize == 0 || srcdata == NULL) return false;
+  if (datasize == 0 || srcdata == nullptr) return false;
 
   // Initialize libjpeg structures to have a memory source
   // Modify the usual jpeg error manager to catch fatal errors.
@@ -449,7 +449,7 @@ bool CompressInternal(const uint8* srcdata, int width, int height,
     return false;
   }
 
-  JOCTET* buffer = 0;
+  JOCTET* buffer = nullptr;
 
   // NOTE: for broader use xmp_metadata should be made a unicode string
   CHECK(srcdata != nullptr);
diff --git a/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc b/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
index edd20371b4e..3d3050cd0d6 100644
--- a/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
+++ b/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
@@ -70,18 +70,18 @@ void TestJPEG(Env* env, const string& jpegfile) {
 
   // Set min_acceptable_fraction to something insufficient
   flags.min_acceptable_fraction = 0.8;
-  imgdata.reset(Uncompress(temp, fsize / 2, flags, &w, &h, &c, NULL));
-  CHECK(imgdata.get() == NULL);
+  imgdata.reset(Uncompress(temp, fsize / 2, flags, &w, &h, &c, nullptr));
+  CHECK(imgdata.get() == nullptr);
 
   // Now, use a value that makes fsize/2 be enough for a black-filling
   flags.min_acceptable_fraction = 0.01;
-  imgdata.reset(Uncompress(temp, fsize / 2, flags, &w, &h, &c, NULL));
-  CHECK(imgdata.get() != NULL);
+  imgdata.reset(Uncompress(temp, fsize / 2, flags, &w, &h, &c, nullptr));
+  CHECK(imgdata.get() != nullptr);
 
   // Finally, uncompress the whole data
   flags.min_acceptable_fraction = 1.0;
-  imgdata.reset(Uncompress(temp, fsize, flags, &w, &h, &c, NULL));
-  CHECK(imgdata.get() != NULL);
+  imgdata.reset(Uncompress(temp, fsize, flags, &w, &h, &c, nullptr));
+  CHECK(imgdata.get() != nullptr);
 }
 
 TEST(JpegMemTest, Jpeg) {
@@ -153,8 +153,8 @@ TEST(JpegMemTest, Jpeg2) {
     UncompressFlags flags;
     flags.components = components;
     int w, h, c;
-    imgdata1.reset(
-        Uncompress(cpdata1.c_str(), cpdata1.length(), flags, &w, &h, &c, NULL));
+    imgdata1.reset(Uncompress(cpdata1.c_str(), cpdata1.length(), flags, &w, &h,
+                              &c, nullptr));
 
     // Check obvious formatting stuff
     CHECK_EQ(w, in_w);
@@ -193,8 +193,8 @@ TEST(JpegMemTest, Jpeg2) {
     flags.components = 3;
     flags.dct_method = JDCT_IFAST;
     int w, h, c;
-    imgdata1.reset(
-        Uncompress(cpdata1.c_str(), cpdata1.length(), flags, &w, &h, &c, NULL));
+    imgdata1.reset(Uncompress(cpdata1.c_str(), cpdata1.length(), flags, &w, &h,
+                              &c, nullptr));
 
     // Check obvious formatting stuff
     CHECK_EQ(w, in_w);
@@ -267,7 +267,7 @@ TEST(JpegMemTest, ChromaDownsampling) {
   int64 num_warnings;
   std::unique_ptr<uint8[]> uncompressed(Uncompress(
       jpeg.c_str(), jpeg.size(), unflags, &w, &h, &c, &num_warnings));
-  CHECK(uncompressed.get() != NULL);
+  CHECK(uncompressed.get() != nullptr);
   CHECK_EQ(num_warnings, 0);
 
   // Recompress the JPEG with and without chroma downsampling
@@ -296,7 +296,7 @@ void TestBadJPEG(Env* env, const string& bad_jpeg_file, int expected_width,
   int width, height, components;
   std::unique_ptr<uint8[]> imgdata;
   imgdata.reset(Uncompress(jpeg.c_str(), jpeg.size(), flags, &width, &height,
-                           &components, NULL));
+                           &components, nullptr));
   if (expected_width > 0) {  // we expect the file to decode into 'something'
     CHECK_EQ(width, expected_width);
     CHECK_EQ(height, expected_height);
diff --git a/tensorflow/core/lib/png/png_io.cc b/tensorflow/core/lib/png/png_io.cc
index 961a78f83b1..354c819b090 100644
--- a/tensorflow/core/lib/png/png_io.cc
+++ b/tensorflow/core/lib/png/png_io.cc
@@ -125,7 +125,8 @@ char* check_metadata_string(const string& s) {
 void CommonFreeDecode(DecodeContext* context) {
   if (context->png_ptr) {
     png_destroy_read_struct(&context->png_ptr,
-                            context->info_ptr ? &context->info_ptr : NULL, 0);
+                            context->info_ptr ? &context->info_ptr : nullptr,
+                            nullptr);
     context->png_ptr = nullptr;
     context->info_ptr = nullptr;
   }
@@ -150,7 +151,7 @@ bool DecodeHeader(StringPiece png_string, int* width, int* height,
   *width = static_cast<int>(context.width);
   CHECK_NOTNULL(height);
   *height = static_cast<int>(context.height);
-  if (components != NULL) {
+  if (components != nullptr) {
     switch (context.color_type) {
       case PNG_COLOR_TYPE_PALETTE:
         *components =
@@ -175,12 +176,12 @@ bool DecodeHeader(StringPiece png_string, int* width, int* height,
         break;
     }
   }
-  if (channel_bit_depth != NULL) {
+  if (channel_bit_depth != nullptr) {
     *channel_bit_depth = context.bit_depth;
   }
-  if (metadata != NULL) {
+  if (metadata != nullptr) {
     metadata->clear();
-    png_textp text_ptr = NULL;
+    png_textp text_ptr = nullptr;
     int num_text = 0;
     png_get_text(context.png_ptr, context.info_ptr, &text_ptr, &num_text);
     for (int i = 0; i < num_text; i++) {
@@ -222,8 +223,8 @@ bool CommonInitDecode(StringPiece png_string, int desired_channels,
   png_set_read_fn(context->png_ptr, context, StringReader);
   png_read_info(context->png_ptr, context->info_ptr);
   png_get_IHDR(context->png_ptr, context->info_ptr, &context->width,
-               &context->height, &context->bit_depth, &context->color_type, 0,
-               0, 0);
+               &context->height, &context->bit_depth, &context->color_type,
+               nullptr, nullptr, nullptr);
   if (context->error_condition) {
     VLOG(1) << ": DecodePNG <- error during header parsing.";
     CommonFreeDecode(context);
@@ -307,7 +308,7 @@ bool CommonFinishDecode(png_bytep data, int row_bytes, DecodeContext* context) {
   for (int p = 0; p < context->num_passes; ++p) {
     png_bytep row = data;
     for (int h = context->height; h-- != 0; row += row_bytes) {
-      png_read_row(context->png_ptr, row, NULL);
+      png_read_row(context->png_ptr, row, nullptr);
     }
   }
 
@@ -339,17 +340,17 @@ bool WriteImageToBuffer(
   if (width == 0 || height == 0) return false;
 
   png_string->resize(0);
-  png_infop info_ptr = NULL;
-  png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
+  png_infop info_ptr = nullptr;
+  png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr,
                                                 ErrorHandler, WarningHandler);
-  if (png_ptr == NULL) return false;
+  if (png_ptr == nullptr) return false;
   if (setjmp(png_jmpbuf(png_ptr))) {
-    png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr : NULL);
+    png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr : nullptr);
     return false;
   }
   info_ptr = png_create_info_struct(png_ptr);
-  if (info_ptr == NULL) {
-    png_destroy_write_struct(&png_ptr, NULL);
+  if (info_ptr == nullptr) {
+    png_destroy_write_struct(&png_ptr, nullptr);
     return false;
   }
 
@@ -400,7 +401,7 @@ bool WriteImageToBuffer(
 
   png_byte* row = reinterpret_cast<png_byte*>(const_cast<void*>(image));
   for (; height--; row += row_bytes) png_write_row(png_ptr, row);
-  png_write_end(png_ptr, NULL);
+  png_write_end(png_ptr, nullptr);
 
   png_destroy_write_struct(&png_ptr, &info_ptr);
   return true;
diff --git a/tensorflow/core/lib/strings/numbers.cc b/tensorflow/core/lib/strings/numbers.cc
index fc07bd446c1..0dea0f89f9b 100644
--- a/tensorflow/core/lib/strings/numbers.cc
+++ b/tensorflow/core/lib/strings/numbers.cc
@@ -166,7 +166,7 @@ char* DoubleToBuffer(double value, char* buffer) {
     DCHECK(snprintf_result > 0 && snprintf_result < kFastToBufferSize);
 
     full_precision_needed =
-        locale_independent_strtonum<double>(buffer, NULL) != value;
+        locale_independent_strtonum<double>(buffer, nullptr) != value;
   }
 
   if (full_precision_needed) {
diff --git a/tensorflow/core/lib/strings/ordered_code_test.cc b/tensorflow/core/lib/strings/ordered_code_test.cc
index 3eac2a3cabc..adb3b8d9437 100644
--- a/tensorflow/core/lib/strings/ordered_code_test.cc
+++ b/tensorflow/core/lib/strings/ordered_code_test.cc
@@ -102,7 +102,7 @@ static T TestRead(const string& a) {
   // gracefully reject any proper prefix of an encoding
   for (int i = 0; i < a.size() - 1; ++i) {
     StringPiece s(a.data(), i);
-    CHECK(!OCRead<T>(&s, NULL));
+    CHECK(!OCRead<T>(&s, nullptr));
     CHECK_EQ(s, a.substr(0, i));
   }
 
@@ -296,7 +296,7 @@ static inline string StrNot(const string& s) {
 template <typename T>
 static void TestInvalidEncoding(const string& s) {
   StringPiece p(s);
-  EXPECT_FALSE(OCRead<T>(&p, static_cast<T*>(NULL)));
+  EXPECT_FALSE(OCRead<T>(&p, static_cast<T*>(nullptr)));
   EXPECT_EQ(s, p);
 }
 
@@ -330,7 +330,8 @@ TEST(OrderedCodeInvalidEncodingsDeathTest, NonCanonical) {
     EXPECT_NE(OCWrite<uint64>(0), non_minimal);
 #ifndef NDEBUG
     StringPiece s(non_minimal);
-    EXPECT_DEATH(OrderedCode::ReadNumIncreasing(&s, NULL), "invalid encoding");
+    EXPECT_DEATH(OrderedCode::ReadNumIncreasing(&s, nullptr),
+                 "invalid encoding");
 #else
     TestRead<uint64>(non_minimal);
 #endif
@@ -348,7 +349,7 @@ TEST(OrderedCodeInvalidEncodingsDeathTest, NonCanonical) {
     EXPECT_NE(OCWrite<int64>(0), non_minimal);
 #ifndef NDEBUG
     StringPiece s(non_minimal);
-    EXPECT_DEATH(OrderedCode::ReadSignedNumIncreasing(&s, NULL),
+    EXPECT_DEATH(OrderedCode::ReadSignedNumIncreasing(&s, nullptr),
                  "invalid encoding")
         << n;
 #else
@@ -439,15 +440,15 @@ TEST(String, EncodeDecode) {
       StringPiece s = out;
       StringPiece s2 = out;
       CHECK(OCRead<string>(&s, &a2));
-      CHECK(OCRead<string>(&s2, NULL));
+      CHECK(OCRead<string>(&s2, nullptr));
       CHECK_EQ(s, s2);
 
       CHECK(OCRead<string>(&s, &b2));
-      CHECK(OCRead<string>(&s2, NULL));
+      CHECK(OCRead<string>(&s2, nullptr));
       CHECK_EQ(s, s2);
 
       CHECK(!OCRead<string>(&s, &dummy));
-      CHECK(!OCRead<string>(&s2, NULL));
+      CHECK(!OCRead<string>(&s2, nullptr));
       CHECK_EQ(a, a2);
       CHECK_EQ(b, b2);
       CHECK(s.empty());
diff --git a/tensorflow/core/lib/strings/stringprintf.cc b/tensorflow/core/lib/strings/stringprintf.cc
index 855734fc144..03eba4c851f 100644
--- a/tensorflow/core/lib/strings/stringprintf.cc
+++ b/tensorflow/core/lib/strings/stringprintf.cc
@@ -52,7 +52,7 @@ void Appendv(string* dst, const char* format, va_list ap) {
       // Error or MSVC running out of space.  MSVC 8.0 and higher
       // can be asked about space needed with the special idiom below:
       va_copy(backup_ap, ap);
-      result = vsnprintf(NULL, 0, format, backup_ap);
+      result = vsnprintf(nullptr, 0, format, backup_ap);
       va_end(backup_ap);
     }
 
diff --git a/tensorflow/core/lib/strings/stringprintf_test.cc b/tensorflow/core/lib/strings/stringprintf_test.cc
index 8d2bc897b0b..d61a1a945ae 100644
--- a/tensorflow/core/lib/strings/stringprintf_test.cc
+++ b/tensorflow/core/lib/strings/stringprintf_test.cc
@@ -66,7 +66,7 @@ TEST(PrintfTest, Multibyte) {
   // out of memory while trying to determine destination buffer size.
   // see b/4194543.
 
-  char* old_locale = setlocale(LC_CTYPE, NULL);
+  char* old_locale = setlocale(LC_CTYPE, nullptr);
   // Push locale with multibyte mode
   setlocale(LC_CTYPE, "en_US.utf8");
 
@@ -95,7 +95,7 @@ TEST(PrintfTest, Multibyte) {
 
 TEST(PrintfTest, NoMultibyte) {
   // No multibyte handling, but the string contains funny chars.
-  char* old_locale = setlocale(LC_CTYPE, NULL);
+  char* old_locale = setlocale(LC_CTYPE, nullptr);
   setlocale(LC_CTYPE, "POSIX");
   string value = Printf("%.*s", 3, "\375\067s");
   setlocale(LC_CTYPE, old_locale);
diff --git a/tensorflow/core/platform/cloud/oauth_client.cc b/tensorflow/core/platform/cloud/oauth_client.cc
index 97d6617a040..7a9588b56ad 100644
--- a/tensorflow/core/platform/cloud/oauth_client.cc
+++ b/tensorflow/core/platform/cloud/oauth_client.cc
@@ -100,14 +100,14 @@ Status CreateSignature(RSA* private_key, StringPiece to_sign,
       EVP_PKEY_new(), [](EVP_PKEY* ptr) { EVP_PKEY_free(ptr); });
   EVP_PKEY_set1_RSA(key.get(), private_key);
 
-  if (EVP_DigestSignInit(md_ctx.get(), NULL, md, NULL, key.get()) != 1) {
+  if (EVP_DigestSignInit(md_ctx.get(), nullptr, md, nullptr, key.get()) != 1) {
     return errors::Internal("DigestInit failed.");
   }
   if (EVP_DigestSignUpdate(md_ctx.get(), to_sign.data(), to_sign.size()) != 1) {
     return errors::Internal("DigestUpdate failed.");
   }
   size_t sig_len = 0;
-  if (EVP_DigestSignFinal(md_ctx.get(), NULL, &sig_len) != 1) {
+  if (EVP_DigestSignFinal(md_ctx.get(), nullptr, &sig_len) != 1) {
     return errors::Internal("DigestFinal (get signature length) failed.");
   }
   std::unique_ptr<unsigned char[]> sig(new unsigned char[sig_len]);
diff --git a/tensorflow/core/platform/cpu_info.cc b/tensorflow/core/platform/cpu_info.cc
index 906826e6f83..5cade740e47 100644
--- a/tensorflow/core/platform/cpu_info.cc
+++ b/tensorflow/core/platform/cpu_info.cc
@@ -110,7 +110,7 @@ class CPUIDInfo {
 
   static void Initialize() {
     // Initialize cpuid struct
-    CHECK(cpuid == NULL) << __func__ << " ran more than once";
+    CHECK(cpuid == nullptr) << __func__ << " ran more than once";
     cpuid = new CPUIDInfo;
 
     uint32 eax, ebx, ecx, edx;
diff --git a/tensorflow/core/platform/port_test.cc b/tensorflow/core/platform/port_test.cc
index 8930e49ff84..15c3cb24f04 100644
--- a/tensorflow/core/platform/port_test.cc
+++ b/tensorflow/core/platform/port_test.cc
@@ -26,7 +26,7 @@ namespace port {
 TEST(Port, AlignedMalloc) {
   for (size_t alignment = 1; alignment <= 1 << 20; alignment <<= 1) {
     void* p = AlignedMalloc(1, alignment);
-    ASSERT_TRUE(p != NULL) << "AlignedMalloc(1, " << alignment << ")";
+    ASSERT_TRUE(p != nullptr) << "AlignedMalloc(1, " << alignment << ")";
     uintptr_t pval = reinterpret_cast<uintptr_t>(p);
     EXPECT_EQ(pval % alignment, 0);
     AlignedFree(p);
@@ -38,14 +38,14 @@ TEST(ConditionVariable, WaitForMilliseconds_Timeout) {
   mutex_lock l(m);
   condition_variable cv;
   ConditionResult result = kCond_MaybeNotified;
-  time_t start = time(NULL);
+  time_t start = time(nullptr);
   // Condition variables are subject to spurious wakeups on some platforms,
   // so need to check for a timeout within a loop.
   while (result == kCond_MaybeNotified) {
     result = WaitForMilliseconds(&l, &cv, 3000);
   }
   EXPECT_EQ(result, kCond_Timeout);
-  time_t finish = time(NULL);
+  time_t finish = time(nullptr);
   EXPECT_GE(finish - start, 3);
 }
 
@@ -54,7 +54,7 @@ TEST(ConditionVariable, WaitForMilliseconds_Signalled) {
   mutex m;
   mutex_lock l(m);
   condition_variable cv;
-  time_t start = time(NULL);
+  time_t start = time(nullptr);
   // Sleep for just 1 second then notify.  We have a timeout of 3 secs,
   // so the condition variable will notice the cv signal before the timeout.
   pool.Schedule([&m, &cv]() {
@@ -63,7 +63,7 @@ TEST(ConditionVariable, WaitForMilliseconds_Signalled) {
     cv.notify_all();
   });
   EXPECT_EQ(WaitForMilliseconds(&l, &cv, 3000), kCond_MaybeNotified);
-  time_t finish = time(NULL);
+  time_t finish = time(nullptr);
   EXPECT_LT(finish - start, 3);
 }
 
diff --git a/tensorflow/core/platform/posix/env_time.cc b/tensorflow/core/platform/posix/env_time.cc
index 15254c1eed0..341c585a9e4 100644
--- a/tensorflow/core/platform/posix/env_time.cc
+++ b/tensorflow/core/platform/posix/env_time.cc
@@ -28,7 +28,7 @@ class PosixEnvTime : public EnvTime {
 
   uint64 NowMicros() override {
     struct timeval tv;
-    gettimeofday(&tv, NULL);
+    gettimeofday(&tv, nullptr);
     return static_cast<uint64>(tv.tv_sec) * 1000000 + tv.tv_usec;
   }
 };
diff --git a/tensorflow/core/platform/posix/port.cc b/tensorflow/core/platform/posix/port.cc
index 66c4ff37b90..6ee402594bf 100644
--- a/tensorflow/core/platform/posix/port.cc
+++ b/tensorflow/core/platform/posix/port.cc
@@ -70,7 +70,7 @@ void* AlignedMalloc(size_t size, int minimum_alignment) {
 #if defined(__ANDROID__)
   return memalign(minimum_alignment, size);
 #else  // !defined(__ANDROID__)
-  void* ptr = NULL;
+  void* ptr = nullptr;
   // posix_memalign requires that the requested alignment be at least
   // sizeof(void*). In this case, fall back on malloc which should return
   // memory aligned to at least the size of a pointer.
@@ -82,7 +82,7 @@ void* AlignedMalloc(size_t size, int minimum_alignment) {
   int err = posix_memalign(&ptr, minimum_alignment, size);
 #endif
   if (err != 0) {
-    return NULL;
+    return nullptr;
   } else {
     return ptr;
   }
diff --git a/tensorflow/core/platform/posix/posix_file_system.cc b/tensorflow/core/platform/posix/posix_file_system.cc
index 2825b37b0ef..fb7a5a99959 100644
--- a/tensorflow/core/platform/posix/posix_file_system.cc
+++ b/tensorflow/core/platform/posix/posix_file_system.cc
@@ -78,7 +78,7 @@ class PosixWritableFile : public WritableFile {
       : filename_(fname), file_(f) {}
 
   ~PosixWritableFile() override {
-    if (file_ != NULL) {
+    if (file_ != nullptr) {
       // Ignoring any potential errors
       fclose(file_);
     }
@@ -97,7 +97,7 @@ class PosixWritableFile : public WritableFile {
     if (fclose(file_) != 0) {
       result = IOError(filename_, errno);
     }
-    file_ = NULL;
+    file_ = nullptr;
     return result;
   }
 
@@ -150,7 +150,7 @@ Status PosixFileSystem::NewWritableFile(const string& fname,
   string translated_fname = TranslateName(fname);
   Status s;
   FILE* f = fopen(translated_fname.c_str(), "w");
-  if (f == NULL) {
+  if (f == nullptr) {
     s = IOError(fname, errno);
   } else {
     result->reset(new PosixWritableFile(translated_fname, f));
@@ -163,7 +163,7 @@ Status PosixFileSystem::NewAppendableFile(
   string translated_fname = TranslateName(fname);
   Status s;
   FILE* f = fopen(translated_fname.c_str(), "a");
-  if (f == NULL) {
+  if (f == nullptr) {
     s = IOError(fname, errno);
   } else {
     result->reset(new PosixWritableFile(translated_fname, f));
@@ -205,11 +205,11 @@ Status PosixFileSystem::GetChildren(const string& dir,
   string translated_dir = TranslateName(dir);
   result->clear();
   DIR* d = opendir(translated_dir.c_str());
-  if (d == NULL) {
+  if (d == nullptr) {
     return IOError(dir, errno);
   }
   struct dirent* entry;
-  while ((entry = readdir(d)) != NULL) {
+  while ((entry = readdir(d)) != nullptr) {
     StringPiece basename = entry->d_name;
     if ((basename != ".") && (basename != "..")) {
       result->push_back(entry->d_name);
diff --git a/tensorflow/core/user_ops/fact.cc b/tensorflow/core/user_ops/fact.cc
index 78ae297ca14..c5122755064 100644
--- a/tensorflow/core/user_ops/fact.cc
+++ b/tensorflow/core/user_ops/fact.cc
@@ -32,7 +32,7 @@ class FactOp : public OpKernel {
 
   void Compute(OpKernelContext* context) override {
     // Output a scalar string.
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, TensorShape(), &output_tensor));
     auto output = output_tensor->template scalar<string>();
diff --git a/tensorflow/core/util/events_writer.cc b/tensorflow/core/util/events_writer.cc
index 7cd040ebd43..3ce2c8ae0b0 100644
--- a/tensorflow/core/util/events_writer.cc
+++ b/tensorflow/core/util/events_writer.cc
@@ -63,7 +63,7 @@ bool EventsWriter::InitIfNeeded() {
     return false;
   }
   recordio_writer_.reset(new io::RecordWriter(recordio_file_.get()));
-  if (recordio_writer_.get() == NULL) {
+  if (recordio_writer_.get() == nullptr) {
     LOG(ERROR) << "Could not create record writer";
     return false;
   }
@@ -90,7 +90,7 @@ string EventsWriter::FileName() {
 }
 
 void EventsWriter::WriteSerializedEvent(StringPiece event_str) {
-  if (recordio_writer_.get() == NULL) {
+  if (recordio_writer_.get() == nullptr) {
     if (!InitIfNeeded()) {
       LOG(ERROR) << "Write failed because file could not be opened.";
       return;
@@ -110,7 +110,7 @@ void EventsWriter::WriteEvent(const Event& event) {
 
 bool EventsWriter::Flush() {
   if (num_outstanding_events_ == 0) return true;
-  CHECK(recordio_file_.get() != NULL) << "Unexpected NULL file";
+  CHECK(recordio_file_.get() != nullptr) << "Unexpected NULL file";
 
   if (!recordio_writer_->Flush().ok()) {
     LOG(ERROR) << "Failed to flush " << num_outstanding_events_ << " events to "
@@ -139,15 +139,15 @@ bool EventsWriter::Flush() {
 
 bool EventsWriter::Close() {
   bool return_value = Flush();
-  if (recordio_file_.get() != NULL) {
+  if (recordio_file_.get() != nullptr) {
     Status s = recordio_file_->Close();
     if (!s.ok()) {
       LOG(ERROR) << "Error when closing previous event file: " << filename_
                  << ": " << s;
       return_value = false;
     }
-    recordio_writer_.reset(NULL);
-    recordio_file_.reset(NULL);
+    recordio_writer_.reset(nullptr);
+    recordio_file_.reset(nullptr);
   }
   num_outstanding_events_ = 0;
   return return_value;
diff --git a/tensorflow/examples/adding_an_op/cuda_op_kernel.cc b/tensorflow/examples/adding_an_op/cuda_op_kernel.cc
index 2f323b43d85..af04258fa2c 100644
--- a/tensorflow/examples/adding_an_op/cuda_op_kernel.cc
+++ b/tensorflow/examples/adding_an_op/cuda_op_kernel.cc
@@ -40,7 +40,7 @@ class AddOneOp : public OpKernel {
     auto input = input_tensor.flat<int32>();
 
     // Create an output tensor
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
                                                      &output_tensor));
     auto output = output_tensor->template flat<int32>();
diff --git a/tensorflow/examples/adding_an_op/zero_out_op_kernel_1.cc b/tensorflow/examples/adding_an_op/zero_out_op_kernel_1.cc
index cc8c719c1ac..6d57b64d1aa 100644
--- a/tensorflow/examples/adding_an_op/zero_out_op_kernel_1.cc
+++ b/tensorflow/examples/adding_an_op/zero_out_op_kernel_1.cc
@@ -43,7 +43,7 @@ class ZeroOutOp : public OpKernel {
     auto input = input_tensor.flat<int32>();
 
     // Create an output tensor
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
                                                      &output_tensor));
     auto output = output_tensor->template flat<int32>();
diff --git a/tensorflow/examples/adding_an_op/zero_out_op_kernel_2.cc b/tensorflow/examples/adding_an_op/zero_out_op_kernel_2.cc
index 3aa18c73071..04c34c59685 100644
--- a/tensorflow/examples/adding_an_op/zero_out_op_kernel_2.cc
+++ b/tensorflow/examples/adding_an_op/zero_out_op_kernel_2.cc
@@ -65,7 +65,7 @@ class ZeroOutOp : public OpKernel {
     auto input = input_tensor.flat<T>();
 
     // Create an output tensor
-    Tensor* output = NULL;
+    Tensor* output = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, input_tensor.shape(), &output));
     auto output_flat = output->template flat<T>();
diff --git a/tensorflow/examples/adding_an_op/zero_out_op_kernel_3.cc b/tensorflow/examples/adding_an_op/zero_out_op_kernel_3.cc
index 76f6efa3340..3d1c4307ada 100644
--- a/tensorflow/examples/adding_an_op/zero_out_op_kernel_3.cc
+++ b/tensorflow/examples/adding_an_op/zero_out_op_kernel_3.cc
@@ -50,7 +50,7 @@ class ZeroOutOp : public OpKernel {
                 errors::InvalidArgument("preserve_index out of range"));
 
     // Create an output tensor
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
                                                      &output_tensor));
     auto output = output_tensor->template flat<int32>();
diff --git a/tensorflow/java/src/main/native/operation_builder_jni.cc b/tensorflow/java/src/main/native/operation_builder_jni.cc
index 4c54eecd9b5..a7696182c7f 100644
--- a/tensorflow/java/src/main/native/operation_builder_jni.cc
+++ b/tensorflow/java/src/main/native/operation_builder_jni.cc
@@ -24,7 +24,7 @@ TF_OperationDescription* requireHandle(JNIEnv* env, jlong handle) {
   if (handle == 0) {
     throwException(env, kIllegalStateException,
                    "Operation has already been built");
-    return 0;
+    return nullptr;
   }
   return reinterpret_cast<TF_OperationDescription*>(handle);
 }
diff --git a/tensorflow/python/lib/core/ndarray_tensor_bridge.cc b/tensorflow/python/lib/core/ndarray_tensor_bridge.cc
index b9a43bd8203..8934d39e473 100644
--- a/tensorflow/python/lib/core/ndarray_tensor_bridge.cc
+++ b/tensorflow/python/lib/core/ndarray_tensor_bridge.cc
@@ -81,25 +81,25 @@ PyTypeObject TensorReleaserType = {
     0,                                /* tp_itemsize */
     /* methods */
     (destructor)TensorReleaser_dealloc, /* tp_dealloc */
-    0,                                  /* tp_print */
-    0,                                  /* tp_getattr */
-    0,                                  /* tp_setattr */
-    0,                                  /* tp_compare */
-    0,                                  /* tp_repr */
-    0,                                  /* tp_as_number */
-    0,                                  /* tp_as_sequence */
-    0,                                  /* tp_as_mapping */
-    0,                                  /* tp_hash */
-    0,                                  /* tp_call */
-    0,                                  /* tp_str */
-    0,                                  /* tp_getattro */
-    0,                                  /* tp_setattro */
-    0,                                  /* tp_as_buffer */
+    nullptr,                            /* tp_print */
+    nullptr,                            /* tp_getattr */
+    nullptr,                            /* tp_setattr */
+    nullptr,                            /* tp_compare */
+    nullptr,                            /* tp_repr */
+    nullptr,                            /* tp_as_number */
+    nullptr,                            /* tp_as_sequence */
+    nullptr,                            /* tp_as_mapping */
+    nullptr,                            /* tp_hash */
+    nullptr,                            /* tp_call */
+    nullptr,                            /* tp_str */
+    nullptr,                            /* tp_getattro */
+    nullptr,                            /* tp_setattro */
+    nullptr,                            /* tp_as_buffer */
     Py_TPFLAGS_DEFAULT,                 /* tp_flags */
     "Wrapped TensorFlow Tensor",        /* tp_doc */
-    0,                                  /* tp_traverse */
-    0,                                  /* tp_clear */
-    0,                                  /* tp_richcompare */
+    nullptr,                            /* tp_traverse */
+    nullptr,                            /* tp_clear */
+    nullptr,                            /* tp_richcompare */
 };
 
 Status TF_DataType_to_PyArray_TYPE(TF_DataType tf_datatype,
diff --git a/tensorflow/stream_executor/lib/demangle.cc b/tensorflow/stream_executor/lib/demangle.cc
index 8abbac34327..8dea7534e54 100644
--- a/tensorflow/stream_executor/lib/demangle.cc
+++ b/tensorflow/stream_executor/lib/demangle.cc
@@ -37,11 +37,11 @@ namespace port {
 string Demangle(const char *mangled) {
   string demangled;
   int status = 0;
-  char *result = NULL;
+  char *result = nullptr;
 #if HAS_CXA_DEMANGLE
-  result = abi::__cxa_demangle(mangled, NULL, NULL, &status);
+  result = abi::__cxa_demangle(mangled, nullptr, nullptr, &status);
 #endif
-  if (status == 0 && result != NULL) {  // Demangling succeeeded.
+  if (status == 0 && result != nullptr) {  // Demangling succeeeded.
     demangled.append(result);
     free(result);
   }
diff --git a/tensorflow/stream_executor/lib/process_state.cc b/tensorflow/stream_executor/lib/process_state.cc
index 849143b9fe2..3d856187f05 100644
--- a/tensorflow/stream_executor/lib/process_state.cc
+++ b/tensorflow/stream_executor/lib/process_state.cc
@@ -41,7 +41,7 @@ bool GetCurrentDirectory(string* dir) {
   std::unique_ptr<char[]> a(new char[len]);
   for (;;) {
     char* p = getcwd(a.get(), len);
-    if (p != NULL) {
+    if (p != nullptr) {
       *dir = p;
       return true;
     } else if (errno == ERANGE) {
diff --git a/tensorflow/tools/tfprof/internal/tfprof_utils.cc b/tensorflow/tools/tfprof/internal/tfprof_utils.cc
index c982834f060..e90253a1bee 100644
--- a/tensorflow/tools/tfprof/internal/tfprof_utils.cc
+++ b/tensorflow/tools/tfprof/internal/tfprof_utils.cc
@@ -110,7 +110,7 @@ bool CaseEqual(StringPiece s1, StringPiece s2) {
 }
 
 bool StringToBool(StringPiece str, bool* value) {
-  CHECK(value != NULL) << "NULL output boolean given.";
+  CHECK(value != nullptr) << "NULL output boolean given.";
   if (CaseEqual(str, "true") || CaseEqual(str, "t") || CaseEqual(str, "yes") ||
       CaseEqual(str, "y") || CaseEqual(str, "1")) {
     *value = true;
diff --git a/tensorflow/user_ops/ackermann_op.cc b/tensorflow/user_ops/ackermann_op.cc
index 0002d658e82..d42ca6f662e 100644
--- a/tensorflow/user_ops/ackermann_op.cc
+++ b/tensorflow/user_ops/ackermann_op.cc
@@ -32,7 +32,7 @@ class AckermannOp : public OpKernel {
 
   void Compute(OpKernelContext* context) override {
     // Output a scalar string.
-    Tensor* output_tensor = NULL;
+    Tensor* output_tensor = nullptr;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, TensorShape(), &output_tensor));
     auto output = output_tensor->scalar<string>();